Class: Collada::Parser::OrderedMap
- Inherits:
-
Object
- Object
- Collada::Parser::OrderedMap
- Includes:
- Enumerable
- Defined in:
- lib/collada/parser/scene.rb,
lib/collada/parser/support.rb
Instance Attribute Summary collapse
-
#indexed ⇒ Object
readonly
Returns the value of attribute indexed.
-
#ordered ⇒ Object
readonly
Returns the value of attribute ordered.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #append(key, value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(ordered, indexed) ⇒ OrderedMap
constructor
A new instance of OrderedMap.
- #keys ⇒ Object
- #size ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(ordered, indexed) ⇒ OrderedMap
Returns a new instance of OrderedMap.
32 33 34 35 |
# File 'lib/collada/parser/scene.rb', line 32 def initialize(ordered, indexed) @ordered = ordered @indexed = indexed end |
Instance Attribute Details
#indexed ⇒ Object (readonly)
Returns the value of attribute indexed.
38 39 40 |
# File 'lib/collada/parser/scene.rb', line 38 def indexed @indexed end |
#ordered ⇒ Object (readonly)
Returns the value of attribute ordered.
37 38 39 |
# File 'lib/collada/parser/scene.rb', line 37 def ordered @ordered end |
Class Method Details
.parse(top, path, id_key = 'id') ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/collada/parser/scene.rb', line 52 def self.parse(top, path, id_key = 'id') ordered = [] indexed = {} top.elements.each(path) do |element| id = element.attributes[id_key] value = (yield element) indexed[id] = value if id ordered << value end return OrderedMap.new(ordered, indexed) end |
Instance Method Details
#[](key) ⇒ Object
40 41 42 |
# File 'lib/collada/parser/scene.rb', line 40 def [] key @indexed[key] end |
#append(key, value) ⇒ Object
60 61 62 63 |
# File 'lib/collada/parser/support.rb', line 60 def append(key, value) @indexed[key] = value @ordered << value end |
#each(&block) ⇒ Object
44 45 46 |
# File 'lib/collada/parser/scene.rb', line 44 def each(&block) @ordered.each(&block) end |
#keys ⇒ Object
40 41 42 |
# File 'lib/collada/parser/support.rb', line 40 def keys @indexed.keys end |
#size ⇒ Object
48 49 50 |
# File 'lib/collada/parser/scene.rb', line 48 def size @ordered.size end |
#values ⇒ Object
44 45 46 |
# File 'lib/collada/parser/support.rb', line 44 def values @ordered end |