Class: Collada::Parser::Input

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(semantic, source, offset = 0) ⇒ Input

‘Vertices` or `Source` are both okay for source.



325
326
327
328
329
# File 'lib/collada/parser/support.rb', line 325

def initialize(semantic, source, offset = 0)
	@semantic = semantic
	@source = source
	@offset = offset
end

Instance Attribute Details

#offsetObject (readonly)

Returns the value of attribute offset.



333
334
335
# File 'lib/collada/parser/support.rb', line 333

def offset
  @offset
end

#semanticObject (readonly)

Returns the value of attribute semantic.



331
332
333
# File 'lib/collada/parser/support.rb', line 331

def semantic
  @semantic
end

#sourceObject (readonly)

Returns the value of attribute source.



332
333
334
# File 'lib/collada/parser/support.rb', line 332

def source
  @source
end

Class Method Details

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

Raises:



343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/collada/parser/support.rb', line 343

def self.parse(doc, element, sources = {})
	semantic = element.attributes['semantic']
	
	if (source_id = element.attributes['source'])
		source_id.sub!(/^#/, '')
		source = sources[source_id]
	end
	
	raise UnsupportedFeature.new("Can't instantiate input with nil source (#{source_id})!") unless source
	
	offset = element.attributes['offset'] || 0
	
	self.new(semantic.downcase.to_sym, source, offset.to_i)
end

Instance Method Details

#[](index) ⇒ Object



339
340
341
# File 'lib/collada/parser/support.rb', line 339

def [] index
	Attribute.new(@semantic, @source[index])
end

#sizeObject



335
336
337
# File 'lib/collada/parser/support.rb', line 335

def size
	@source.accessor.count
end