Class: GraphViz::Types::GvBool
Constant Summary
collapse
- BOOL_TRUE =
["true", "yes"]
- BOOL_FALSE =
["false", "no", ""]
Instance Method Summary
collapse
Instance Method Details
#check(data) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/graphviz/types/gv_bool.rb', line 23
def check(data)
if true == data or (data.is_a?(Integer) and data != 0) or (data.is_a?(String) and !BOOL_FALSE.include?(data.downcase))
@to_ruby = true
return data
end
if false == data or (data.is_a?(Integer) and data == 0) or (data.is_a?(String) and BOOL_FALSE.include?(data.downcase))
@to_ruby = false
return data
end
raise BoolException, "Invalid bool value"
end
|
#output ⇒ Object
Also known as:
to_gv, to_s
37
38
39
|
# File 'lib/graphviz/types/gv_bool.rb', line 37
def output
return @data.to_s.inspect.gsub( "\\\\", "\\" )
end
|
44
45
46
|
# File 'lib/graphviz/types/gv_bool.rb', line 44
def to_ruby
@to_ruby
end
|