Class: Alf::Engine::Group::Hash
- Inherits:
-
Object
- Object
- Alf::Engine::Group::Hash
- Includes:
- Cog
- Defined in:
- lib/alf-engine/alf/engine/group/hash.rb
Overview
Provides hash-based grouping.
Instance Attribute Summary collapse
-
#allbut ⇒ Boolean
readonly
Group all but specified attributes?.
-
#as ⇒ AttrName
readonly
Name of the new attribute.
-
#attributes ⇒ AttrList
readonly
Attributes to group.
-
#operand ⇒ Enumerable
readonly
The operand.
Instance Method Summary collapse
- #_each(&block) ⇒ Object
-
#initialize(operand, attributes, as, allbut) ⇒ Hash
constructor
Creates a Group::Hash instance.
Methods included from Cog
Constructor Details
#initialize(operand, attributes, as, allbut) ⇒ Hash
Creates a Group::Hash instance
22 23 24 25 26 27 |
# File 'lib/alf-engine/alf/engine/group/hash.rb', line 22 def initialize(operand, attributes, as, allbut) @operand = operand @attributes = attributes @as = as @allbut = allbut end |
Instance Attribute Details
#allbut ⇒ Boolean (readonly)
Returns Group all but specified attributes?.
19 20 21 |
# File 'lib/alf-engine/alf/engine/group/hash.rb', line 19 def allbut @allbut end |
#as ⇒ AttrName (readonly)
Returns Name of the new attribute.
16 17 18 |
# File 'lib/alf-engine/alf/engine/group/hash.rb', line 16 def as @as end |
#attributes ⇒ AttrList (readonly)
Returns Attributes to group.
13 14 15 |
# File 'lib/alf-engine/alf/engine/group/hash.rb', line 13 def attributes @attributes end |
#operand ⇒ Enumerable (readonly)
Returns The operand.
10 11 12 |
# File 'lib/alf-engine/alf/engine/group/hash.rb', line 10 def operand @operand end |
Instance Method Details
#_each(&block) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/alf-engine/alf/engine/group/hash.rb', line 30 def _each(&block) atr, alb = @attributes, @allbut index = Materialize::Hash.new(operand, atr, !alb) index.each_pair do |k,v| grouped = Clip.new(v, atr, alb).to_relation yield k.merge(@as => grouped) end end |