Class: So::Lt

Inherits:
Expr show all
Defined in:
lib/spec_object.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expr

#!, #<, #==, #>, #[], #assert_time, #assert_value, #to_so_expr

Constructor Details

#initialize(a, b) ⇒ Lt

Returns a new instance of Lt.



122
123
124
125
# File 'lib/spec_object.rb', line 122

def initialize(a, b)
  @a = a
  @b = b
end

Class Method Details

.lt(a, b) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/spec_object.rb', line 127

def self.lt(a, b)
  a = a.to_so_expr
  b = b.to_so_expr

  if a.kind_of?(Const) && b.kind_of?(Const)
    a.value < b.value
  elsif a.kind_of?(Time) && b.kind_of?(Time)
    a.n < b.n
  else
    new(a, b)
  end
end

Instance Method Details

#evaluate(calls) ⇒ Object



148
149
150
# File 'lib/spec_object.rb', line 148

def evaluate(calls)
  Lt.lt(@a.evaluate(calls), @b.evaluate(calls))
end

#pp(n) ⇒ Object



140
141
142
# File 'lib/spec_object.rb', line 140

def pp(n)
  "#{' '*n}(<\n#{@a.pp(n+2)}\n#{@b.pp(n+2)})"
end

#substitute(v, e) ⇒ Object



144
145
146
# File 'lib/spec_object.rb', line 144

def substitute(v, e)
  Lt.lt(@a.substitute(v, e), @b.substitute(v, e))
end