-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.rb
49 lines (43 loc) · 932 Bytes
/
output.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class Connection
def initialize(user, password)
@user, @password = user, password
end
def inspect
"#<#{self.class} @user=#{@user} @password=#{@password.to_s.gsub(/./, '*')}>"
end
end
class Text
@@defaults = {
font_size: 3,
font_family: "Palatino",
margin: 20,
padding: 5,
leter_spacing: 3
}
class Properties < Hash
def pretty_print(pp)
pp.group 0, "{", "}" do
self.each_pair do |k, v|
pp.comma_breakable
pp.text "#{k}"
pp.pp v
end
end
end
end
def initialize(value, properties = {})
@value = value
@properties = Properties[@@defaults.merge(properties)]
end
def pretty_print(pp)
pp.object_address_group self do
pp.breakable
pp.text "@value="
pp.pp @value
pp.breakable
pp.text "@properties="
pp.pp @properties
end
end
alias inspect pretty_print_inspect
end