Class: Melbourne::AST::Ensure

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

Overview

An ensure statement as in:

begin
  do
rescue
  puts 'error'
ensure
  clean
end

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph

Constructor Details

#initialize(line, body, ensr) ⇒ Ensure

Returns a new instance of Ensure.



48
49
50
51
52
# File 'lib/melbourne/ast/exceptions.rb', line 48

def initialize(line, body, ensr)
  @line = line
  @body = body || Nil.new(line)
  @ensure = ensr
end

Instance Attribute Details

#bodyObject

The body of the ensure statement



42
43
44
# File 'lib/melbourne/ast/exceptions.rb', line 42

def body
  @body
end

#ensureObject

A literal if one is defined as the only statement in the ensure statement



46
47
48
# File 'lib/melbourne/ast/exceptions.rb', line 46

def ensure
  @ensure
end