Class: HashMath::Unpivot::PivotSet
- Inherits:
-
Object
- Object
- HashMath::Unpivot::PivotSet
- Extended by:
- Forwardable
- Defined in:
- lib/hash_math/unpivot/pivot_set.rb
Overview
A set of pivots for an Unpivot class to perform.
Instance Attribute Summary collapse
-
#pivots ⇒ Object
readonly
Returns the value of attribute pivots.
Instance Method Summary collapse
-
#add(pivot) ⇒ Object
Adds another Pivot configuration object to this objects list of pivots.
-
#expand(hash) ⇒ Object
An aggregation of Pivot#expand.
-
#initialize(pivots: []) ⇒ PivotSet
constructor
A new instance of PivotSet.
Constructor Details
Instance Attribute Details
#pivots ⇒ Object (readonly)
Returns the value of attribute pivots.
19 20 21 |
# File 'lib/hash_math/unpivot/pivot_set.rb', line 19 def pivots @pivots end |
Instance Method Details
#add(pivot) ⇒ Object
Adds another Pivot configuration object to this objects list of pivots. Returns self.
29 30 31 |
# File 'lib/hash_math/unpivot/pivot_set.rb', line 29 def add(pivot) tap { pivots << Pivot.make(pivot) } end |
#expand(hash) ⇒ Object
An aggregation of Pivot#expand. This method will iterate over all pivots and expand them all out.
35 36 37 38 39 |
# File 'lib/hash_math/unpivot/pivot_set.rb', line 35 def (hash) # :nodoc: base_hash = make_base_hash(hash) pivots.map { |pivot| pivot.(base_hash, hash) } end |