Class: Collada::Parser::Parameter

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

Direct Known Subclasses

MatrixParameter, VectorParameter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type) ⇒ Parameter

Returns a new instance of Parameter.



158
159
160
161
# File 'lib/collada/parser/support.rb', line 158

def initialize(name, type)
	@name = name ? name.to_sym : nil
	@type = type
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



163
164
165
# File 'lib/collada/parser/support.rb', line 163

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



164
165
166
# File 'lib/collada/parser/support.rb', line 164

def type
  @type
end

Class Method Details

.parse(doc, element) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/collada/parser/support.rb', line 174

def self.parse(doc, element)
	name = element.attributes['name']
	type = element.attributes['type']
	
	case type
	when /float(\d)x(\d)/
		MatrixParameter.new(name, type, [$1.to_i, $2.to_i])
	when /float(\d)/
		VectorParameter.new(name, type, [$1.to_i, $2.to_i])
	else
		Parameter.new(name, type)
	end
end

Instance Method Details

#read(value) ⇒ Object



170
171
172
# File 'lib/collada/parser/support.rb', line 170

def read value
	value.first
end

#sizeObject



166
167
168
# File 'lib/collada/parser/support.rb', line 166

def size
	1
end