Class: So::Variable

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

Instance Method Summary collapse

Methods inherited from Expr

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

Constructor Details

#initializeVariable

Returns a new instance of Variable.



81
82
83
84
# File 'lib/spec_object.rb', line 81

def initialize
  @is_time = false
  @is_value = false
end

Instance Method Details

#assert_timeObject



115
116
117
118
# File 'lib/spec_object.rb', line 115

def assert_time
  @is_time = true
  raise "variable used as both value and time" if @is_value
end

#assert_valueObject



110
111
112
113
# File 'lib/spec_object.rb', line 110

def assert_value
  @is_value = true
  raise "variable used as both value and time" if @is_time
end

#evaluate(calls) ⇒ Object



106
107
108
# File 'lib/spec_object.rb', line 106

def evaluate(calls)
  self
end

#pp(n) ⇒ Object



94
95
96
# File 'lib/spec_object.rb', line 94

def pp(n)
  "#{' '*n}v#{object_id}"
end

#substitute(v, e) ⇒ Object



98
99
100
101
102
103
104
# File 'lib/spec_object.rb', line 98

def substitute(v, e)
  if v.object_id == self.object_id
    e
  else
    self
  end
end

#time?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/spec_object.rb', line 86

def time?
  @is_time
end

#value?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/spec_object.rb', line 90

def value?
  @is_value
end