Class: HashMath::Matrix::KeyValuePair
- Inherits:
-
Object
- Object
- HashMath::Matrix::KeyValuePair
- Defined in:
- lib/hash_math/matrix/key_value_pair.rb
Overview
A hash-like structure that allows you to gradually build up keys.
Defined Under Namespace
Classes: Pair
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #add(val) ⇒ Object
- #add_each(vals) ⇒ Object
-
#initialize(key) ⇒ KeyValuePair
constructor
A new instance of KeyValuePair.
- #pairs ⇒ Object
Constructor Details
#initialize(key) ⇒ KeyValuePair
Returns a new instance of KeyValuePair.
18 19 20 21 22 23 |
# File 'lib/hash_math/matrix/key_value_pair.rb', line 18 def initialize(key) @key = key @value = Set.new freeze end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
16 17 18 |
# File 'lib/hash_math/matrix/key_value_pair.rb', line 16 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
16 17 18 |
# File 'lib/hash_math/matrix/key_value_pair.rb', line 16 def value @value end |
Instance Method Details
#add(val) ⇒ Object
29 30 31 |
# File 'lib/hash_math/matrix/key_value_pair.rb', line 29 def add(val) tap { value << val } end |
#add_each(vals) ⇒ Object
25 26 27 |
# File 'lib/hash_math/matrix/key_value_pair.rb', line 25 def add_each(vals) tap { vals.each { |val| add(val) } } end |