Module: Chelsy::NodeList
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Included in:
- Block, Document, EnumMemberList, FragmentList, IdentList, InitializerList, ParamList, ProtoParamList, StructOrUnionMemberList
- Defined in:
- lib/chelsy/ast.rb
Overview
The class must provide a method validate_node`
Instance Method Summary collapse
- #<<(node) ⇒ Object
- #[]=(*args) ⇒ Object
- #concat(enumerable) ⇒ Object
- #each(&block) ⇒ Object
- #initialize(items = [], **rest) ⇒ Object
Instance Method Details
#<<(node) ⇒ Object
43 44 45 46 |
# File 'lib/chelsy/ast.rb', line 43 def <<(node) @items << validate_node(node) self end |
#[]=(*args) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/chelsy/ast.rb', line 53 def []=(*args) value = args[-1] value = case value when Enumerable value.map {|v| validate_node(v) } else validate_node(value) end args[-1] = value @items.send(:[]=, *args) end |
#concat(enumerable) ⇒ Object
48 49 50 51 |
# File 'lib/chelsy/ast.rb', line 48 def concat(enumerable) enumerable.each {|it| @items << validate_node(it) } self end |
#each(&block) ⇒ Object
38 39 40 41 |
# File 'lib/chelsy/ast.rb', line 38 def each(&block) @items.each(&block) self end |
#initialize(items = [], **rest) ⇒ Object
33 34 35 36 |
# File 'lib/chelsy/ast.rb', line 33 def initialize(items=[], **rest) @items = items.map {|element| validate_node(element) } super(**rest) end |