2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
|
|
|
# Logical Statements are guaranteed to return boolean
|
|
|
|
# either :and or :or, which may be written as && and ||
|
2018-09-01 14:14:07 +02:00
|
|
|
#
|
|
|
|
# Also they guarantee that the right expression does not get evaluated
|
|
|
|
# if the whole expression fails on the left expression.
|
|
|
|
# ie: false && non_existant_method
|
|
|
|
# will never call the non_existant_method , but instead evaluate to false
|
|
|
|
#
|
2019-10-03 23:36:49 +02:00
|
|
|
# Sol has no concept of this, so the Statement is expanded into the if
|
2018-09-01 14:14:07 +02:00
|
|
|
# that it really is
|
2018-07-19 13:46:51 +02:00
|
|
|
class LogicalStatement < Statement
|
|
|
|
attr_reader :name , :left , :right
|
|
|
|
|
|
|
|
def initialize(name , left , right)
|
|
|
|
@name , @left , @right = name , left , right
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s(depth = 0)
|
|
|
|
at_depth(depth , "#{left} #{name} #{right}")
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|