Class: Elparser::SExpCons
- Inherits:
-
AbstractSExpCons
- Object
- AbstractSExp
- AbstractSExpCons
- Elparser::SExpCons
- Defined in:
- lib/elparser.rb
Instance Attribute Summary collapse
-
#car ⇒ Object
readonly
Returns the value of attribute car.
-
#cdr ⇒ Object
readonly
Returns the value of attribute cdr.
Instance Method Summary collapse
-
#initialize(car, cdr) ⇒ SExpCons
constructor
A new instance of SExpCons.
- #to_ruby ⇒ Object
- #to_s ⇒ Object
- #visit ⇒ Object
Methods inherited from AbstractSExpCons
Methods inherited from AbstractSExp
Constructor Details
#initialize(car, cdr) ⇒ SExpCons
Returns a new instance of SExpCons.
121 122 123 124 |
# File 'lib/elparser.rb', line 121 def initialize(car, cdr) @car = car @cdr = cdr end |
Instance Attribute Details
#car ⇒ Object (readonly)
Returns the value of attribute car.
120 121 122 |
# File 'lib/elparser.rb', line 120 def car @car end |
#cdr ⇒ Object (readonly)
Returns the value of attribute cdr.
120 121 122 |
# File 'lib/elparser.rb', line 120 def cdr @cdr end |
Instance Method Details
#to_ruby ⇒ Object
136 137 138 |
# File 'lib/elparser.rb', line 136 def to_ruby [@car.to_ruby, @cdr.to_ruby] end |
#to_s ⇒ Object
129 130 131 132 133 134 135 |
# File 'lib/elparser.rb', line 129 def to_s if @cdr.class == SExpList then "(#{@car} "+@cdr.list.map{|i| i.to_s }.join(" ")+")" else "(#{@car} . #{@cdr})" end end |
#visit ⇒ Object
125 126 127 128 |
# File 'lib/elparser.rb', line 125 def visit @car = yield @car @cdr = yield @cdr end |