Class: GraphViz::DOTScriptData
Instance Attribute Summary collapse
- 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute type. 
Instance Method Summary collapse
- #add_attribute(name, value) ⇒ Object
- #append(data) ⇒ Object (also: #<<)
- #empty? ⇒ Boolean
- 
  
    
      #initialize(type = nil)  ⇒ DOTScriptData 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of DOTScriptData. 
- #to_str ⇒ Object (also: #to_s)
Constructor Details
#initialize(type = nil) ⇒ DOTScriptData
Returns a new instance of DOTScriptData.
| 6 7 8 9 10 | # File 'lib/graphviz/dot_script.rb', line 6 def initialize(type = nil) @data = [] @separator = "" @type = type end | 
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
| 5 6 7 | # File 'lib/graphviz/dot_script.rb', line 5 def type @type end | 
Instance Method Details
#add_attribute(name, value) ⇒ Object
| 17 18 19 20 | # File 'lib/graphviz/dot_script.rb', line 17 def add_attribute(name, value) @data << @separator << name << " = " << value @separator = determine_separator end | 
#append(data) ⇒ Object Also known as: <<
| 12 13 14 | # File 'lib/graphviz/dot_script.rb', line 12 def append(data) @data << data end | 
#empty? ⇒ Boolean
| 32 33 34 | # File 'lib/graphviz/dot_script.rb', line 32 def empty? @data.empty? end | 
#to_str ⇒ Object Also known as: to_s
| 22 23 24 25 26 27 28 29 | # File 'lib/graphviz/dot_script.rb', line 22 def to_str case @type when "graph_attr" then "#{@data.join}#{@separator}" when "node_attr" then "node[#{@data.join(' ')}];" when "edge_attr" then "edge[#{@data.join(' ')}];" else raise ArgumentError, "Wrong type: #{@type}." end end |