Class: Opal::Sexp

Inherits:
Object show all
Defined in:
opal/lib/opal/parser/sexp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Sexp

Returns a new instance of Sexp



8
9
10
# File 'opal/lib/opal/parser/sexp.rb', line 8

def initialize(args)
  @array = args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



24
25
26
# File 'opal/lib/opal/parser/sexp.rb', line 24

def method_missing(sym, *args, &block)
  @array.send sym, *args, &block
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array



4
5
6
# File 'opal/lib/opal/parser/sexp.rb', line 4

def array
  @array
end

#sourceObject

Returns the value of attribute source



6
7
8
# File 'opal/lib/opal/parser/sexp.rb', line 6

def source
  @source
end

Instance Method Details

#<<(other) ⇒ Object



28
29
30
31
# File 'opal/lib/opal/parser/sexp.rb', line 28

def <<(other)
  @array << other
  self
end

#==(other) ⇒ Object Also known as: eql?



46
47
48
49
50
51
52
# File 'opal/lib/opal/parser/sexp.rb', line 46

def ==(other)
  if other.is_a? Sexp
    @array == other.array
  else
    @array == other
  end
end

#childrenObject



20
21
22
# File 'opal/lib/opal/parser/sexp.rb', line 20

def children
  @array[1..-1]
end

#columnObject



60
61
62
# File 'opal/lib/opal/parser/sexp.rb', line 60

def column
  @source && @source[1]
end

#dupObject



42
43
44
# File 'opal/lib/opal/parser/sexp.rb', line 42

def dup
  Sexp.new(@array.dup)
end

#inspectObject Also known as: to_s



64
65
66
# File 'opal/lib/opal/parser/sexp.rb', line 64

def inspect
  "(#{@array.map { |e| e.inspect }.join ', '})"
end

#lineObject



56
57
58
# File 'opal/lib/opal/parser/sexp.rb', line 56

def line
  @source && @source[0]
end

#pretty_inspectObject



68
69
70
# File 'opal/lib/opal/parser/sexp.rb', line 68

def pretty_inspect
  "(#{line ? "#{line} " : ''}#{@array.map { |e| e.inspect }.join ', '})"
end

#push(*parts) ⇒ Object



33
34
35
36
# File 'opal/lib/opal/parser/sexp.rb', line 33

def push(*parts)
  @array.push(*parts)
  self
end

#to_aryObject



38
39
40
# File 'opal/lib/opal/parser/sexp.rb', line 38

def to_ary
  @array
end

#typeObject



12
13
14
# File 'opal/lib/opal/parser/sexp.rb', line 12

def type
  @array[0]
end

#type=(type) ⇒ Object



16
17
18
# File 'opal/lib/opal/parser/sexp.rb', line 16

def type=(type)
  @array[0] = type
end