Class: Natsuzora::Contract::AST::List

Inherits:
Node
  • Object
show all
Defined in:
lib/natsuzora/contract/ast/list.rb

Overview

Ordered list of items of a single contract type. Serialized as ‘kind’ => ‘array’ for JSON compatibility.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ List

Returns a new instance of List.



13
14
15
16
# File 'lib/natsuzora/contract/ast/list.rb', line 13

def initialize(items)
  super()
  @items = items
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



11
12
13
# File 'lib/natsuzora/contract/ast/list.rb', line 11

def items
  @items
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/natsuzora/contract/ast/list.rb', line 22

def ==(other)
  other.is_a?(List) && other.items == @items
end

#to_hObject



18
19
20
# File 'lib/natsuzora/contract/ast/list.rb', line 18

def to_h
  { 'kind' => 'array', 'items' => @items.to_h }
end