Class: Rucoa::Nodes::BlockNode

Inherits:
Base
  • Object
show all
Includes:
Rucoa::NodeConcerns::Body, Rucoa::NodeConcerns::Rescue
Defined in:
lib/rucoa/nodes/block_node.rb

Instance Method Summary collapse

Methods included from Rucoa::NodeConcerns::Rescue

#ensure, #rescue

Methods included from Rucoa::NodeConcerns::Body

#body, #body_children

Methods inherited from Base

#ancestors, #child_nodes, #descendant_nodes, #each_ancestor, #each_child_node, #each_descendant_node, #include_position?, #initialize, #module_nesting, #namespace, #next_sibling_nodes, #parent, #parent=, #previous_sibling_nodes, #updated

Constructor Details

This class inherits a constructor from Rucoa::Nodes::Base

Instance Method Details

#argumentsArray<Rucoa::Nodes::ArgNode>

Examples:

returns arguments

node = Rucoa::Source.new(
  content: <<~RUBY,
    foo do |bar, baz|
    end
  RUBY
  uri: 'file:///path/to/example.rb'
).root_node
expect(node.arguments.map(&:name)).to eq(%w[bar baz])

Returns:



19
20
21
# File 'lib/rucoa/nodes/block_node.rb', line 19

def arguments
  children[-2]
end

#send_nodeRucoa::Nodes::SendNode

Examples:

returns send node

node = Rucoa::Source.new(
  content: <<~RUBY,
    foo do
    end
  RUBY
  uri: 'file:///foo.rb'
).root_node
expect(node.send_node.name).to eq('foo')

Returns:



33
34
35
# File 'lib/rucoa/nodes/block_node.rb', line 33

def send_node
  children[0]
end