Class: BBSexp::Expression

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/bbsexp/expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sym, state, args = {}) ⇒ Expression

Returns a new instance of Expression.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bbsexp/expression.rb', line 6

def initialize(sym, state, args={})
  @sym = sym
  @state = case state
           when :block   then 3
           when :inline  then 2
           when :func    then 1
           when :noparse then 0
           else state
           end
  @tags = args[:tags] || ['', '']
  @block = args[:func]
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/bbsexp/expression.rb', line 4

def block
  @block
end

#stateObject (readonly)

Returns the value of attribute state.



4
5
6
# File 'lib/bbsexp/expression.rb', line 4

def state
  @state
end

#symObject (readonly)

Returns the value of attribute sym.



4
5
6
# File 'lib/bbsexp/expression.rb', line 4

def sym
  @sym
end

#tagsObject (readonly)

Returns the value of attribute tags.



4
5
6
# File 'lib/bbsexp/expression.rb', line 4

def tags
  @tags
end

Instance Method Details

#<=>(b) ⇒ Object



19
20
21
# File 'lib/bbsexp/expression.rb', line 19

def <=>(b)
  @state <=> (b.class == Expression ? b.state : b.to_i)
end