Class: JPath::Parser::Operator

Inherits:
Object
  • Object
show all
Defined in:
lib/jpath/parser/formula.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(char) ⇒ Operator

Returns a new instance of Operator.



26
27
28
29
# File 'lib/jpath/parser/formula.rb', line 26

def initialize(char)
  @char  = char
  @parts = []
end

Instance Attribute Details

#charObject (readonly)

Returns the value of attribute char.



22
23
24
# File 'lib/jpath/parser/formula.rb', line 22

def char
  @char
end

#partsObject (readonly)

Returns the value of attribute parts.



24
25
26
# File 'lib/jpath/parser/formula.rb', line 24

def parts
  @parts
end

Instance Method Details

#+(other) ⇒ Object



35
36
37
# File 'lib/jpath/parser/formula.rb', line 35

def +(other)
  add(other)
end

#add(other) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/jpath/parser/formula.rb', line 39

def add(other)
  @parts << other
  if parts.size < 2
    self
  else
    Formula.new(char, parts)
  end
end

#boolean?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/jpath/parser/formula.rb', line 31

def boolean?
  false
end

#to_sObject



48
49
50
# File 'lib/jpath/parser/formula.rb', line 48

def to_s
  char.to_s
end