Class: Sexpir::Case
- Defined in:
- lib/sexpir/ast.rb,
lib/sexpir/ast_sexp.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#expr ⇒ Object
Returns the value of attribute expr.
-
#whens ⇒ Object
Returns the value of attribute whens.
Attributes inherited from Ast
Instance Method Summary collapse
-
#initialize ⇒ Case
constructor
A new instance of Case.
- #sexp ⇒ Object
Methods inherited from Ast
Constructor Details
#initialize ⇒ Case
Returns a new instance of Case.
74 75 76 |
# File 'lib/sexpir/ast.rb', line 74 def initialize @whens=[] end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
73 74 75 |
# File 'lib/sexpir/ast.rb', line 73 def default @default end |
#expr ⇒ Object
Returns the value of attribute expr.
73 74 75 |
# File 'lib/sexpir/ast.rb', line 73 def expr @expr end |
#whens ⇒ Object
Returns the value of attribute whens.
73 74 75 |
# File 'lib/sexpir/ast.rb', line 73 def whens @whens end |
Instance Method Details
#sexp ⇒ Object
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 |