Class: Alf::Engine::Coerce
- Inherits:
-
Object
- Object
- Alf::Engine::Coerce
- Includes:
- Cog
- Defined in:
- lib/alf-engine/alf/engine/coerce.rb
Overview
Coerce input tuples according to a Heading. Attributes that do not belong to the heading are simply ignored but are kept in the output.
Example:
operand = [
{:name => "Jones", :price => "10.0"},
{:name => "Smith", :price => "-12.0"}
]
Coerce.new(operand, Heading[:price => Float]).to_a
# => [
# {:name => "Jones", :price => 10.0},
# {:name => "Smith", :price => -12.0}
# ]
Instance Attribute Summary collapse
-
#coercions ⇒ Heading
readonly
Heading for coercions.
-
#operand ⇒ Enumerable
readonly
The operand.
Instance Method Summary collapse
- #_each ⇒ Object
-
#initialize(operand, coercions) ⇒ Coerce
constructor
Creates an Coerce instance.
Methods included from Cog
Constructor Details
#initialize(operand, coercions) ⇒ Coerce
Creates an Coerce instance
30 31 32 33 |
# File 'lib/alf-engine/alf/engine/coerce.rb', line 30 def initialize(operand, coercions) @operand = operand @coercions = coercions end |
Instance Attribute Details
#coercions ⇒ Heading (readonly)
Returns Heading for coercions.
27 28 29 |
# File 'lib/alf-engine/alf/engine/coerce.rb', line 27 def coercions @coercions end |
#operand ⇒ Enumerable (readonly)
Returns The operand.
24 25 26 |
# File 'lib/alf-engine/alf/engine/coerce.rb', line 24 def operand @operand end |