Class: GraphViz::Attrs
- Inherits:
-
Object
- Object
- GraphViz::Attrs
- Defined in:
- lib/graphviz/attrs.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #[](xKey) ⇒ Object
- #[]=(xKey, xValue) ⇒ Object
- #each ⇒ Object
-
#initialize(gviz, name, attributs) ⇒ Attrs
constructor
A new instance of Attrs.
- #to_h ⇒ Object
Constructor Details
Instance Attribute Details
#data ⇒ Object
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
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/graphviz/attrs.rb', line 43 def []( xKey ) if xKey.class == Hash xKey.each do |k, v| self[k] = v end else if @data.key?( xKey.to_s ) == false nil end @data[xKey.to_s] end end |
#[]=(xKey, xValue) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/graphviz/attrs.rb', line 56 def []=( xKey, xValue ) unless @attributs.keys.include?( xKey.to_s ) raise ArgumentError, "#{@name} attribut '#{xKey.to_s}' invalid" end @data[xKey.to_s] = GraphViz::Types.const_get(@attributs[xKey.to_s]).new( xValue ) if @graphviz.nil? == false @graphviz.set_position( @name, xKey.to_s, @data[xKey.to_s] ) end end |
#each ⇒ Object
33 34 35 36 37 |
# File 'lib/graphviz/attrs.rb', line 33 def each @data.each do |k, v| yield(k, v) end end |
#to_h ⇒ Object
39 40 41 |
# File 'lib/graphviz/attrs.rb', line 39 def to_h @data.clone end |