Class: Sexpir::If
Instance Attribute Summary collapse
-
#cond ⇒ Object
Returns the value of attribute cond.
-
#else ⇒ Object
Returns the value of attribute else.
-
#elsifs ⇒ Object
Returns the value of attribute elsifs.
-
#then ⇒ Object
Returns the value of attribute then.
Attributes inherited from Ast
Instance Method Summary collapse
-
#initialize ⇒ If
constructor
A new instance of If.
- #sexp ⇒ Object
Methods inherited from Ast
Constructor Details
#initialize ⇒ If
67 68 69 |
# File 'lib/sexpir/ast.rb', line 67 def initialize @elsifs=[] end |
Instance Attribute Details
#cond ⇒ Object
Returns the value of attribute cond.
66 67 68 |
# File 'lib/sexpir/ast.rb', line 66 def cond @cond end |
#else ⇒ Object
Returns the value of attribute else.
66 67 68 |
# File 'lib/sexpir/ast.rb', line 66 def else @else end |
#elsifs ⇒ Object
Returns the value of attribute elsifs.
66 67 68 |
# File 'lib/sexpir/ast.rb', line 66 def elsifs @elsifs end |
#then ⇒ Object
Returns the value of attribute then.
66 67 68 |
# File 'lib/sexpir/ast.rb', line 66 def then @then end |
Instance Method Details
#sexp ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/sexpir/ast_sexp.rb', line 112 def sexp code=Code.new code << "(if #{cond.sexp}" code.indent=2 code << "(then" code.indent=4 code << self.then.sexp code.indent=2 code << ")" if self.else code << "(else" code.indent=4 code << self.else.sexp code.indent=2 code << ")" end code.indent=0 code << ")" code end |