Class: Cassanity::CollectionItem
- Inherits:
-
Object
- Object
- Cassanity::CollectionItem
- Defined in:
- lib/cassanity/collection_item.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Internal.
-
#value ⇒ Object
readonly
Internal.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(key, value) ⇒ CollectionItem
constructor
Public: Returns a collection item instance.
-
#inspect ⇒ Object
Public.
Constructor Details
#initialize(key, value) ⇒ CollectionItem
Public: Returns a collection item instance
14 15 16 17 18 19 20 |
# File 'lib/cassanity/collection_item.rb', line 14 def initialize(key, value) raise ArgumentError.new("key cannot be nil") if key.nil? raise ArgumentError.new("value cannot be nil") if value.nil? @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object (readonly)
Internal
8 9 10 |
# File 'lib/cassanity/collection_item.rb', line 8 def key @key end |
#value ⇒ Object (readonly)
Internal
11 12 13 |
# File 'lib/cassanity/collection_item.rb', line 11 def value @value end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
22 23 24 25 26 |
# File 'lib/cassanity/collection_item.rb', line 22 def eql?(other) self.class.eql?(other.class) && value == other.value && key == other.key end |
#inspect ⇒ Object
Public
31 32 33 34 35 36 37 |
# File 'lib/cassanity/collection_item.rb', line 31 def inspect attributes = [ "key=#{key.inspect}", "value=#{value.inspect}", ] "#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>" end |