Class: Cecil::Node
- Inherits:
-
Object
- Object
- Cecil::Node
- Defined in:
- lib/cecil/node.rb
Overview
rubocop:disable Style/Documentation
Defined Under Namespace
Classes: Deferred, Detached, Literal, LiteralWithChildren, SameLineContainer, Template
Instance Method Summary collapse
-
#<<(string_or_node) ⇒ Node
Append a string or node to the node, without making a new line.
-
#[] ⇒ Node
Alias of #with.
-
#with(*positional_values, **named_values) ⇒ Node
Provide values for placeholders and/or nest a block of code.
Instance Method Details
#<<(string_or_node) ⇒ Node
Append a string or node to the node, without making a new line.
141 142 143 144 145 146 |
# File 'lib/cecil/node.rb', line 141 def <<(string_or_node) SameLineContainer.new(parent:).tap do |container| container.add_child self replace_with container end << string_or_node end |
#[] ⇒ Node
Alias of #with
114 115 116 117 |
# File 'lib/cecil/node.rb', line 114 def [](...) # don't use alias/alias_method b/c subclasses overriding `with` need `[]` to call `self.with` with(...) end |
#with(*positional_values) ⇒ Node #with(**named_values) ⇒ Node #with(*positional_values, &) ⇒ Node #with(**named_values, &) ⇒ Node #with(&) ⇒ Node
Provide values for placeholders and/or nest a block of code. When called, will replace this node with a Literal or LiteralWithChildren.
Placeholder values can be given as positional arguments or named values, but not both.
When called with a block, the block is called immediately and any source code emitted is nested under the current block.
110 |
# File 'lib/cecil/node.rb', line 110 def with(*positional_values, **named_values, &) = raise "Not implemented" # rubocop:disable Lint/UnusedMethodArgument |