Class: GraphViz::Types::GvBool

Inherits:
Common show all
Defined in:
lib/graphviz/types/gv_bool.rb

Constant Summary

BOOL_TRUE =
["true", "yes"]
BOOL_FALSE =
["false", "no", ""]

Instance Method Summary (collapse)

Methods inherited from Common

#initialize, #source

Constructor Details

This class inherits a constructor from GraphViz::Types::Common

Instance Method Details

- (Object) check(data)

Raises:



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

- (Object) output 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

- (Object) to_ruby



44
45
46
# File 'lib/graphviz/types/gv_bool.rb', line 44

def to_ruby
   @to_ruby
end