Class: SoberSwag::Nodes::List
Overview
Instance Attribute Summary collapse
- #element ⇒ SoberSwag::Nodes::Base readonly
Instance Method Summary collapse
-
#cata(&block) ⇒ Object
Maps over the element type, then this
List
type. - #deconstruct ⇒ Array(SoberSwag::Nodes::Base)
-
#deconstruct_keys(_) ⇒ Hash{Symbol => SoberSwag::Nodes::Base}
The contained type wrapped in an
element:
key. -
#initialize(element) ⇒ List
constructor
Initialize with a node representing the type of elements in the list.
-
#map(&block) ⇒ Object
Maps over the element type.
Methods inherited from Base
Constructor Details
#initialize(element) ⇒ List
Initialize with a node representing the type of elements in the list.
15 16 17 |
# File 'lib/sober_swag/nodes/list.rb', line 15 def initialize(element) @element = element end |
Instance Attribute Details
#element ⇒ SoberSwag::Nodes::Base (readonly)
21 22 23 |
# File 'lib/sober_swag/nodes/list.rb', line 21 def element @element end |
Instance Method Details
#cata(&block) ⇒ Object
Maps over the element type, then this List
type.
40 41 42 43 44 45 46 |
# File 'lib/sober_swag/nodes/list.rb', line 40 def cata(&block) block.call( self.class.new( element.cata(&block) ) ) end |
#deconstruct ⇒ Array(SoberSwag::Nodes::Base)
25 26 27 |
# File 'lib/sober_swag/nodes/list.rb', line 25 def deconstruct [element] end |
#deconstruct_keys(_) ⇒ Hash{Symbol => SoberSwag::Nodes::Base}
Returns the contained type wrapped in an element:
key.
32 33 34 |
# File 'lib/sober_swag/nodes/list.rb', line 32 def deconstruct_keys(_) { element: element } end |
#map(&block) ⇒ Object
Maps over the element type.
52 53 54 55 56 |
# File 'lib/sober_swag/nodes/list.rb', line 52 def map(&block) self.class.new( element.map(&block) ) end |