Class: Odin::Types::OdinArray
Instance Attribute Summary collapse
Attributes inherited from OdinValue
#directives, #modifiers
Instance Method Summary
collapse
Methods inherited from OdinValue
#array?, #binary?, #boolean?, #confidential?, #currency?, #date?, #deprecated?, #duration?, #integer?, #null?, #number?, #numeric?, #object?, #percent?, #reference?, #required?, #string?, #temporal?, #time?, #timestamp?, #verb?
Constructor Details
#initialize(items: [], **kwargs) ⇒ OdinArray
Returns a new instance of OdinArray.
539
540
541
542
543
|
# File 'lib/odin/types/values.rb', line 539
def initialize(items: [], **kwargs)
super(**kwargs)
@items = items.freeze
freeze
end
|
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
537
538
539
|
# File 'lib/odin/types/values.rb', line 537
def items
@items
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
554
555
556
|
# File 'lib/odin/types/values.rb', line 554
def ==(other)
other.is_a?(OdinArray) && items == other.items
end
|
#[](index) ⇒ Object
550
|
# File 'lib/odin/types/values.rb', line 550
def [](index); items[index]; end
|
#empty? ⇒ Boolean
552
|
# File 'lib/odin/types/values.rb', line 552
def empty?; items.empty?; end
|
#hash ⇒ Object
559
560
561
|
# File 'lib/odin/types/values.rb', line 559
def hash
[ValueType::ARRAY, items].hash
end
|
#size ⇒ Object
Also known as:
length
547
|
# File 'lib/odin/types/values.rb', line 547
def size; items.size; end
|
#to_s ⇒ Object
563
564
565
|
# File 'lib/odin/types/values.rb', line 563
def to_s
"[#{items.size} items]"
end
|
#type ⇒ Object
545
|
# File 'lib/odin/types/values.rb', line 545
def type; ValueType::ARRAY; end
|
#with_directives(dirs) ⇒ Object
571
572
573
|
# File 'lib/odin/types/values.rb', line 571
def with_directives(dirs)
OdinArray.new(items: items, modifiers: modifiers, directives: dirs)
end
|
#with_modifiers(mods) ⇒ Object
567
568
569
|
# File 'lib/odin/types/values.rb', line 567
def with_modifiers(mods)
OdinArray.new(items: items, modifiers: mods, directives: directives)
end
|