Class: Pocolog::Upgrade::Ops::ArrayCast
- Defined in:
- lib/pocolog/upgrade/ops/array_cast.rb
Overview
Converts to an array
Instance Attribute Summary collapse
-
#element_ops ⇒ Object
readonly
Returns the value of attribute element_ops.
Attributes inherited from Base
Instance Method Summary collapse
- #call(target, value) ⇒ Object
-
#initialize(to_type, element_ops) ⇒ ArrayCast
constructor
A new instance of ArrayCast.
Methods inherited from Base
Constructor Details
#initialize(to_type, element_ops) ⇒ ArrayCast
Returns a new instance of ArrayCast
8 9 10 11 |
# File 'lib/pocolog/upgrade/ops/array_cast.rb', line 8 def initialize(to_type, element_ops) super(to_type) @element_ops = element_ops end |
Instance Attribute Details
#element_ops ⇒ Object (readonly)
Returns the value of attribute element_ops
6 7 8 |
# File 'lib/pocolog/upgrade/ops/array_cast.rb', line 6 def element_ops @element_ops end |
Instance Method Details
#call(target, value) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pocolog/upgrade/ops/array_cast.rb', line 13 def call(target, value) if value.size != to_type.length raise ArraySizeMismatch, "attempting to copy a container of size #{value.size} into an array of size #{to_type.length}" end i = 0 value.raw_each do |sample| element_ops.call(target.raw_get(i), sample) i += 1 end end |