Class: Vissen::Parameterized::Value::Vec
- Inherits:
-
Object
- Object
- Vissen::Parameterized::Value::Vec
- Includes:
- Vissen::Parameterized::Value
- Defined in:
- lib/vissen/parameterized/value/vec.rb
Overview
Vector type values are stored internally as arrays of floats.
Usage
vec = Vec[1, 0.2]
vec.value # => [1.0, 0.2]
Constant Summary collapse
- DEFAULT =
Returns the default value that will be used when ‘.new` is called without arguments, or with nil.
[0.0, 0.0].freeze
Instance Attribute Summary
Attributes included from Vissen::Parameterized::Value
Class Method Summary collapse
-
.[](a, b) ⇒ Vec
A new Vec instance.
Instance Method Summary collapse
-
#initialize(initial_value = nil) ⇒ Vec
constructor
A new instance of Vec.
- #write(new_value) ⇒ true, false
Methods included from Vissen::Parameterized::Value
canonicalize, #scope, #tainted?, #to_s, types, #untaint!
Constructor Details
Class Method Details
.[](a, b) ⇒ Vec
Returns a new Vec instance.
49 50 51 |
# File 'lib/vissen/parameterized/value/vec.rb', line 49 def [](a, b) new [a, b] end |
Instance Method Details
#write(new_value) ⇒ true, false
35 36 37 38 39 40 41 42 43 |
# File 'lib/vissen/parameterized/value/vec.rb', line 35 def write(new_value) return if @value == new_value @value[0] = Float(new_value[0]) @value[1] = Float(new_value[1]) taint! rescue NoMethodError raise TypeError, 'The given object must support #[]' end |