Class: Cecil::Node
- Inherits:
-
Object
- Object
- Cecil::Node
- Defined in:
- lib/cecil/node.rb
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.
137 138 139 140 141 142 |
# File 'lib/cecil/node.rb', line 137 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
110 111 112 113 |
# File 'lib/cecil/node.rb', line 110 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.
106 |
# File 'lib/cecil/node.rb', line 106 def with(*positional_values, **named_values, &) = raise "Not implemented" # rubocop:disable Lint/UnusedMethodArgument |