Class: Elparser::SExpListDot
- Inherits:
-
AbstractSExpCons
- Object
- AbstractSExp
- AbstractSExpCons
- Elparser::SExpListDot
- Defined in:
- lib/elparser.rb
Overview
(list . last)
Instance Method Summary collapse
- #car ⇒ Object
- #cdr ⇒ Object
-
#initialize(list, last) ⇒ SExpListDot
constructor
A new instance of SExpListDot.
- #list? ⇒ Boolean
- #to_ruby ⇒ Object
- #to_s ⇒ Object
- #visit(&block) ⇒ Object
Methods inherited from AbstractSExpCons
Methods inherited from AbstractSExp
Constructor Details
#initialize(list, last) ⇒ SExpListDot
Returns a new instance of SExpListDot.
183 184 185 186 |
# File 'lib/elparser.rb', line 183 def initialize(list, last) @list = list @last = last end |
Instance Method Details
#car ⇒ Object
187 188 189 |
# File 'lib/elparser.rb', line 187 def car @list[0] end |
#cdr ⇒ Object
190 191 192 193 194 195 196 |
# File 'lib/elparser.rb', line 190 def cdr if @list.size == 2 then SExpCons.new(@list[1], @last) else SExpListDot.new(@list.slice(1..-1),@last) end end |
#list? ⇒ Boolean
197 198 199 |
# File 'lib/elparser.rb', line 197 def list? false end |
#to_ruby ⇒ Object
207 208 209 |
# File 'lib/elparser.rb', line 207 def to_ruby @list.map {|i| i.to_ruby}.push(@last.to_ruby) end |
#to_s ⇒ Object
200 201 202 |
# File 'lib/elparser.rb', line 200 def to_s "("+@list.map{|i| i.to_s }.join(" ") + " . #{@last.to_s})" end |
#visit(&block) ⇒ Object
203 204 205 206 |
# File 'lib/elparser.rb', line 203 def visit(&block) @list = @list.map(&block) @last = block.call(@last) end |