Class: Melbourne::AST::Block

Inherits:
Node
  • Object
show all
Defined in:
lib/melbourne/ast/definitions.rb

Overview

A code block as in:

begin
end

but also as in (implicit block):

a = 1; b = 2

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph

Constructor Details

#initialize(line, array) ⇒ Block

Returns a new instance of Block.



64
65
66
67
# File 'lib/melbourne/ast/definitions.rb', line 64

def initialize(line, array)
  @line = line
  @array = array
end

Instance Attribute Details

#arrayObject

The statements inside of the block



62
63
64
# File 'lib/melbourne/ast/definitions.rb', line 62

def array
  @array
end

Instance Method Details

#strip_argumentsObject

TODO: document!



70
71
72
73
74
75
76
77
78
# File 'lib/melbourne/ast/definitions.rb', line 70

def strip_arguments
  if @array.first.kind_of? FormalArguments
    node = @array.shift
    if @array.first.kind_of? BlockArgument
      node.block_arg = @array.shift
    end
    return node
  end
end