Class: Keisan::AST::Boolean
Instance Attribute Summary collapse
Instance Method Summary
collapse
#==, #evaluate, #to_s
Methods inherited from Node
#%, #&, #*, #**, #+, #+@, #-, #-@, #/, #<, #<<, #<=, #>, #>=, #>>, #^, #coerce, #contains_a?, #deep_dup, #differentiate, #differentiated, #evaluate, #evaluate_assignments, #evaluated, #false?, #replace, #replaced, #simplified, #simplify, #to_cell, #to_node, #traverse, #unbound_functions, #unbound_variables, #well_defined?, #|, #~
Constructor Details
#initialize(bool) ⇒ Boolean
Returns a new instance of Boolean.
6
7
8
|
# File 'lib/keisan/ast/boolean.rb', line 6
def initialize(bool)
@bool = bool
end
|
Instance Attribute Details
#bool ⇒ Object
Returns the value of attribute bool.
4
5
6
|
# File 'lib/keisan/ast/boolean.rb', line 4
def bool
@bool
end
|
Instance Method Details
#! ⇒ Object
18
19
20
|
# File 'lib/keisan/ast/boolean.rb', line 18
def !
Boolean.new(!bool)
end
|
#and(other) ⇒ Object
22
23
24
25
|
# File 'lib/keisan/ast/boolean.rb', line 22
def and(other)
other = other.to_node
other.is_a?(Boolean) ? Boolean.new(bool && other.bool) : super
end
|
#equal(other) ⇒ Object
32
33
34
35
|
# File 'lib/keisan/ast/boolean.rb', line 32
def equal(other)
other = other.to_node
other.is_a?(Boolean) ? Boolean.new(value == other.value) : super
end
|
#not_equal(other) ⇒ Object
37
38
39
40
|
# File 'lib/keisan/ast/boolean.rb', line 37
def not_equal(other)
other = other.to_node
other.is_a?(Boolean) ? Boolean.new(value != other.value) : super
end
|
#or(other) ⇒ Object
27
28
29
30
|
# File 'lib/keisan/ast/boolean.rb', line 27
def or(other)
other = other.to_node
other.is_a?(Boolean) ? Boolean.new(bool || other.bool) : super
end
|
14
15
16
|
# File 'lib/keisan/ast/boolean.rb', line 14
def true?
bool
end
|
#value(context = nil) ⇒ Object
10
11
12
|
# File 'lib/keisan/ast/boolean.rb', line 10
def value(context = nil)
bool
end
|