Class: Collada::Parser::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/collada/parser/support.rb

Overview

A source that reads directly from a data array:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, accessor) ⇒ Source

Returns a new instance of Source.



293
294
295
296
# File 'lib/collada/parser/support.rb', line 293

def initialize(id, accessor)
	@id = id
	@accessor = accessor
end

Instance Attribute Details

#accessorObject (readonly)

Returns the value of attribute accessor.



299
300
301
# File 'lib/collada/parser/support.rb', line 299

def accessor
  @accessor
end

#idObject (readonly)

Returns the value of attribute id.



298
299
300
# File 'lib/collada/parser/support.rb', line 298

def id
  @id
end

Class Method Details

.parse(doc, element, arrays = {}) ⇒ Object



301
302
303
304
305
# File 'lib/collada/parser/support.rb', line 301

def self.parse(doc, element, arrays = {})
	accessor = Accessor.parse(doc, element.elements['technique_common/accessor'], arrays)
	
	self.new(element.attributes['id'], accessor)
end

.parse_arrays(doc, element) ⇒ Object



307
308
309
310
311
312
313
314
315
316
# File 'lib/collada/parser/support.rb', line 307

def self.parse_arrays(doc, element)
	OrderedMap.parse(element, '//float_array | //int_array | //Name_array') do |array_element|
		case array_element.name
		when 'Name_array'
			array_element.text.strip.split(/\s+/)
		else
			array_element.text.strip.split(/\s+/).collect &:to_f
		end
	end
end

Instance Method Details

#[](index) ⇒ Object



318
319
320
# File 'lib/collada/parser/support.rb', line 318

def [] index
	Hash[@accessor[index]]
end