Class: GraphViz::Attrs

Inherits:
Object
  • Object
show all
Defined in:
lib/graphviz/attrs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gviz, name, attributs) ⇒ Attrs

Returns a new instance of Attrs.



26
27
28
29
30
31
# File 'lib/graphviz/attrs.rb', line 26

def initialize( gviz, name, attributs )
  @name      = name
  @attributs = attributs
  @data      = Hash::new( )
 @graphviz  = gviz
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



24
25
26
# File 'lib/graphviz/attrs.rb', line 24

def data
  @data
end

Instance Method Details

#[](xKey) ⇒ Object



33
34
35
36
37
38
# File 'lib/graphviz/attrs.rb', line 33

def []( xKey )
  if @data.key?( xKey.to_s ) == false
    nil
  end
  @data[xKey.to_s]
end

#[]=(xKey, xValue) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/graphviz/attrs.rb', line 40

def []=( xKey, xValue )
  if @attributs.index( xKey.to_s ).nil? == true
    raise ArgumentError, "#{@name} attribut '#{xKey.to_s}' invalid"
  end
  @data[xKey.to_s] = xValue.to_s

  if @graphviz.nil? == false
    @graphviz.set_position( @name, xKey.to_s, xValue.to_s )
  end
end