class Elparser::SExpList

Attributes

list[R]

Public Class Methods

new(list) click to toggle source
# File lib/elparser.rb, line 143
def initialize(list)
  @list = list
end

Public Instance Methods

alist?() click to toggle source
# File lib/elparser.rb, line 168
def alist?
  @list.all? {|i| i.cons? }
end
car() click to toggle source
# File lib/elparser.rb, line 146
def car
  @list[0]
end
cdr() click to toggle source
# File lib/elparser.rb, line 149
def cdr
  if @list.size == 1
    SExpNil.new
  else
    SExpList.new @list.slice(1..-1)
  end
end
list?() click to toggle source
# File lib/elparser.rb, line 156
def list?
  true
end
to_h() click to toggle source

alist -> hash

# File lib/elparser.rb, line 172
def to_h
  ret = Hash.new
  @list.each do |i|
    ret[i.car.to_ruby] = i.cdr.to_ruby
  end
  ret
end
to_ruby() click to toggle source
# File lib/elparser.rb, line 165
def to_ruby
  @list.map {|i| i.to_ruby}
end
to_s() click to toggle source
# File lib/elparser.rb, line 159
def to_s
  "("+@list.map{|i| i.to_s }.join(" ")+")"
end
visit(&block) click to toggle source
# File lib/elparser.rb, line 162
def visit(&block)
  @list = @list.map(&block)
end