Class: Elparser::SExpCons

Inherits:
AbstractSExpCons show all
Defined in:
lib/elparser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractSExpCons

#cons?

Methods inherited from AbstractSExp

#==, #atom?, #cons?, #list?

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

#carObject (readonly)

Returns the value of attribute car.



120
121
122
# File 'lib/elparser.rb', line 120

def car
  @car
end

#cdrObject (readonly)

Returns the value of attribute cdr.



120
121
122
# File 'lib/elparser.rb', line 120

def cdr
  @cdr
end

Instance Method Details

#to_rubyObject



136
137
138
# File 'lib/elparser.rb', line 136

def to_ruby
  [@car.to_ruby, @cdr.to_ruby]
end

#to_sObject



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

#visitObject



125
126
127
128
# File 'lib/elparser.rb', line 125

def visit
  @car = yield @car
  @cdr = yield @cdr
end