Class: Odin::Types::OdinArrayItem
- Inherits:
-
Object
- Object
- Odin::Types::OdinArrayItem
- Defined in:
- lib/odin/types/array_item.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(kind:, value: nil, fields: nil) ⇒ OdinArrayItem
constructor
A new instance of OdinArrayItem.
- #record? ⇒ Boolean
- #value? ⇒ Boolean
Constructor Details
#initialize(kind:, value: nil, fields: nil) ⇒ OdinArrayItem
Returns a new instance of OdinArrayItem.
16 17 18 19 20 21 |
# File 'lib/odin/types/array_item.rb', line 16 def initialize(kind:, value: nil, fields: nil) @kind = kind @value = value @fields = fields&.freeze freeze end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
6 7 8 |
# File 'lib/odin/types/array_item.rb', line 6 def fields @fields end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
6 7 8 |
# File 'lib/odin/types/array_item.rb', line 6 def kind @kind end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/odin/types/array_item.rb', line 6 def value @value end |
Class Method Details
.from_value(value) ⇒ Object
8 9 10 |
# File 'lib/odin/types/array_item.rb', line 8 def self.from_value(value) new(kind: :value, value: value) end |
.record(fields) ⇒ Object
12 13 14 |
# File 'lib/odin/types/array_item.rb', line 12 def self.record(fields) new(kind: :record, fields: fields) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
31 32 33 34 |
# File 'lib/odin/types/array_item.rb', line 31 def ==(other) other.is_a?(OdinArrayItem) && kind == other.kind && value == other.value && fields == other.fields end |
#hash ⇒ Object
37 38 39 |
# File 'lib/odin/types/array_item.rb', line 37 def hash [kind, value, fields].hash end |
#record? ⇒ Boolean
23 24 25 |
# File 'lib/odin/types/array_item.rb', line 23 def record? kind == :record end |
#value? ⇒ Boolean
27 28 29 |
# File 'lib/odin/types/array_item.rb', line 27 def value? kind == :value end |