Class: HashMath::Matrix
- Inherits:
-
Object
- Object
- HashMath::Matrix
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/hash_math/matrix.rb,
lib/hash_math/matrix/key_value_pair.rb
Overview
A Matrix allows you to build up a hash of key and values, then it will generate the product of all values.
Defined Under Namespace
Classes: KeyValuePair
Instance Method Summary collapse
- #add(key, val) ⇒ Object
- #add_each(key, vals) ⇒ Object
-
#initialize ⇒ Matrix
constructor
A new instance of Matrix.
Constructor Details
#initialize ⇒ Matrix
Returns a new instance of Matrix.
21 22 23 24 25 |
# File 'lib/hash_math/matrix.rb', line 21 def initialize @pairs_by_key = {} freeze end |
Instance Method Details
#add(key, val) ⇒ Object
31 32 33 |
# File 'lib/hash_math/matrix.rb', line 31 def add(key, val) tap { kvp(key).add(val) } end |
#add_each(key, vals) ⇒ Object
27 28 29 |
# File 'lib/hash_math/matrix.rb', line 27 def add_each(key, vals) tap { kvp(key).add_each(vals) } end |