class HashMath::Unpivot::PivotSet

A set of pivots for an Unpivot class to perform.

Attributes

pivots[R]

Public Class Methods

new(pivots: []) click to toggle source
# File lib/hash_math/unpivot/pivot_set.rb, line 23
def initialize(pivots: [])
  @pivots = Pivot.array(pivots)
end

Public Instance Methods

add(pivot) click to toggle source

Adds another Pivot configuration object to this objects list of pivots. Returns self.

# File lib/hash_math/unpivot/pivot_set.rb, line 29
def add(pivot)
  tap { pivots << Pivot.make(pivot) }
end

Private Instance Methods

key_set() click to toggle source
# File lib/hash_math/unpivot/pivot_set.rb, line 49
def key_set
  pivots.flat_map(&:keys).to_set
end
make_base_hash(hash) click to toggle source
# File lib/hash_math/unpivot/pivot_set.rb, line 43
def make_base_hash(hash)
  keys_to_remove = key_set

  hash.reject { |k, _v| keys_to_remove.include?(k) }
end