Class: Sexpir::Case

Inherits:
Ast
  • Object
show all
Defined in:
lib/sexpir/ast.rb,
lib/sexpir/ast_sexp.rb

Instance Attribute Summary collapse

Attributes inherited from Ast

#node

Instance Method Summary collapse

Methods inherited from Ast

#accept

Constructor Details

#initializeCase

Returns a new instance of Case.



74
75
76
# File 'lib/sexpir/ast.rb', line 74

def initialize
  @whens=[]
end

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



73
74
75
# File 'lib/sexpir/ast.rb', line 73

def default
  @default
end

#exprObject

Returns the value of attribute expr.



73
74
75
# File 'lib/sexpir/ast.rb', line 73

def expr
  @expr
end

#whensObject

Returns the value of attribute whens.



73
74
75
# File 'lib/sexpir/ast.rb', line 73

def whens
  @whens
end

Instance Method Details

#sexpObject



136
137
138
139
140
141
142
143
144
145
# File 'lib/sexpir/ast_sexp.rb', line 136

def sexp
  code=Code.new
  code << "(case #{expr.sexp}"
  code.indent=2
  whens.each{|when_| code << when_.sexp}
  code << self.default.sexp
  code.indent=0
  code << ")"
  code
end