Class: GraphViz::Types::Rect

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

Constant Summary

FLOAT_MASK =
/[-+]?(?:[0-9]*\.[0-9]+|[0-9]+)/
RECT_FINAL_MASK =
/#{FLOAT_MASK}\s*,\s*#{FLOAT_MASK}\s*,\s*#{FLOAT_MASK}\s*,\s*#{FLOAT_MASK}/

Instance Method Summary collapse

Methods inherited from Common

#initialize, #source

Constructor Details

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

Instance Method Details

#check(data) ⇒ Object

Raises:



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/graphviz/types/rect.rb', line 10

def check(data)
  if data.is_a?(String) and RECT_FINAL_MASK.match(data)
     @to_ruby = data.split(",").map{ |e| e.to_f }
     return data
  end
  if data.is_a?(Array)
     return check(data.join(","))
  end
  return nil if data.is_a?(String) and data.empty?

  raise RectException, "Invalid rect value"
end

#outputObject Also known as: to_gv, to_s



23
24
25
# File 'lib/graphviz/types/rect.rb', line 23

def output
  return @data.to_s.inspect.gsub( "\\\\", "\\" )
end

#to_rubyObject



30
31
32
# File 'lib/graphviz/types/rect.rb', line 30

def to_ruby
   @to_ruby
end