Class: Alf::Engine::Clip
Overview
Clips input tuples keeping (all but) specific attributes only.
Example:
operand = [
{:name => "Jones", :city => "London"},
{:name => "Smith", :city => "Paris"}
]
Clip.new(operand, AttrList[:name], false).to_a
# => [
# {:name => "Jones"},
# {:name => "Smith"}
# ]
Clip.new(operand, AttrList[:name], true).to_a
# => [
# {:city => "London"},
# {:city => "Paris"}
# ]
Constant Summary
Constants included from Cog
Alf::Engine::Cog::EMPTY_CHILDREN, Alf::Engine::Cog::EMPTY_OPTIONS
Instance Attribute Summary collapse
-
#allbut ⇒ Boolean
readonly
Clip *all but* attributes?.
-
#attributes ⇒ AttrList
readonly
List of attributes for clipping.
-
#operand ⇒ Enumerable
readonly
The operand.
Attributes included from Compiler::Cog
Instance Method Summary collapse
- #_each ⇒ Object
- #arguments ⇒ Object
-
#initialize(operand, attributes, allbut, expr = nil, compiler = nil) ⇒ Clip
constructor
Creates an Clip instance.
- #options ⇒ Object
Methods included from Cog
Methods included from Compiler::Cog
#cog_orders, #orderedby?, #relation_type, #to_ascii_tree, #to_cog, #to_relation
Constructor Details
#initialize(operand, attributes, allbut, expr = nil, compiler = nil) ⇒ Clip
Creates an Clip instance
38 39 40 41 42 43 |
# File 'lib/alf/engine/clip.rb', line 38 def initialize(operand, attributes, allbut, expr = nil, compiler = nil) super(expr, compiler) @operand = operand @attributes = attributes @allbut = allbut end |
Instance Attribute Details
#allbut ⇒ Boolean (readonly)
Returns Clip *all but* attributes?.
35 36 37 |
# File 'lib/alf/engine/clip.rb', line 35 def allbut @allbut end |
#attributes ⇒ AttrList (readonly)
Returns List of attributes for clipping.
32 33 34 |
# File 'lib/alf/engine/clip.rb', line 32 def attributes @attributes end |
#operand ⇒ Enumerable (readonly)
Returns The operand.
29 30 31 |
# File 'lib/alf/engine/clip.rb', line 29 def operand @operand end |
Instance Method Details
#_each ⇒ Object
46 47 48 49 50 |
# File 'lib/alf/engine/clip.rb', line 46 def _each @operand.each do |tuple| yield @attributes.project_tuple(tuple, @allbut) end end |
#arguments ⇒ Object
52 53 54 |
# File 'lib/alf/engine/clip.rb', line 52 def arguments [attributes] end |
#options ⇒ Object
56 57 58 |
# File 'lib/alf/engine/clip.rb', line 56 def {allbut: allbut} end |