Class: Collada::Parser::OrderedMap

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/collada/parser/scene.rb,
lib/collada/parser/support.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#indexedObject (readonly)

Returns the value of attribute indexed.



38
39
40
# File 'lib/collada/parser/scene.rb', line 38

def indexed
  @indexed
end

#orderedObject (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

#keysObject



40
41
42
# File 'lib/collada/parser/support.rb', line 40

def keys
	@indexed.keys
end

#sizeObject



48
49
50
# File 'lib/collada/parser/scene.rb', line 48

def size
	@ordered.size
end

#valuesObject



44
45
46
# File 'lib/collada/parser/support.rb', line 44

def values
	@ordered
end