Class: Collada::Parser::Attribute
- Inherits:
-
Object
- Object
- Collada::Parser::Attribute
- Defined in:
- lib/collada/parser/support.rb
Instance Attribute Summary collapse
-
#semantic ⇒ Object
readonly
Returns the value of attribute semantic.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
- .flatten(attributes) ⇒ Object
- .merge(attributes) ⇒ Object
- .method_missing(method, *args) ⇒ Object
- .to_hash(attributes) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #flatten ⇒ Object
-
#initialize(semantic, value) ⇒ Attribute
constructor
A new instance of Attribute.
- #inspect ⇒ Object
Constructor Details
#initialize(semantic, value) ⇒ Attribute
Returns a new instance of Attribute.
108 109 110 111 |
# File 'lib/collada/parser/support.rb', line 108 def initialize(semantic, value) @semantic = semantic @value = value end |
Instance Attribute Details
#semantic ⇒ Object (readonly)
Returns the value of attribute semantic.
113 114 115 |
# File 'lib/collada/parser/support.rb', line 113 def semantic @semantic end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
114 115 116 |
# File 'lib/collada/parser/support.rb', line 114 def value @value end |
Class Method Details
.flatten(attributes) ⇒ Object
144 145 146 |
# File 'lib/collada/parser/support.rb', line 144 def self.flatten(attributes) attributes.collect{|attribute| attribute.flatten}.flatten end |
.merge(attributes) ⇒ Object
152 153 154 |
# File 'lib/collada/parser/support.rb', line 152 def self.merge(attributes) attributes.collect{|attribute| attribute.value}.inject(:merge) end |
.method_missing(method, *args) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/collada/parser/support.rb', line 128 def self.method_missing(method, *args) if args.size == 1 && Hash === args[0] new(method, args[0]) else new(method, args) end end |
.to_hash(attributes) ⇒ Object
148 149 150 |
# File 'lib/collada/parser/support.rb', line 148 def self.to_hash(attributes) Hash[attributes.collect{|attribute| [attribute.semantic, attribute.value]}] end |
Instance Method Details
#==(other) ⇒ Object
120 121 122 |
# File 'lib/collada/parser/support.rb', line 120 def == other @value == other.value end |
#[](key) ⇒ Object
116 117 118 |
# File 'lib/collada/parser/support.rb', line 116 def [] key @value[key] end |
#flatten ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/collada/parser/support.rb', line 136 def flatten if Array === @value @value.collect{|attribute| attribute.flatten} else self end end |
#inspect ⇒ Object
124 125 126 |
# File 'lib/collada/parser/support.rb', line 124 def inspect "Attribute.#{@semantic}(#{@value.inspect})" end |