Class: Code::Object::Boolean
- Inherits:
-
Code::Object
- Object
- Code::Object
- Code::Object::Boolean
- Defined in:
- lib/code/object/boolean.rb
Constant Summary
Constants inherited from Code::Object
Instance Attribute Summary
Attributes included from Concerns::Shared
Instance Method Summary collapse
- #call(**args) ⇒ Object
- #code_bitwise_and(other) ⇒ Object
- #code_bitwise_or(other) ⇒ Object
- #code_bitwise_xor(other) ⇒ Object
-
#initialize(*args, **_kargs, &_block) ⇒ Boolean
constructor
A new instance of Boolean.
- #truthy? ⇒ Boolean
Methods inherited from Code::Object
code_new, #code_new, maybe, #name, repeat, |
Methods included from Concerns::Shared
#<=>, #==, #as_json, #code_and, #code_as_json, #code_deep_duplicate, #code_different, #code_duplicate, #code_equal, #code_exclamation_mark, #code_exclusive_range, #code_falsy?, #code_fetch, code_fetch, #code_get, code_get, #code_inclusive_range, #code_inspect, #code_methods, #code_name, #code_nothing?, #code_or, #code_self, #code_set, code_set, #code_something?, #code_strict_different, #code_strict_equal, #code_to_boolean, #code_to_class, #code_to_date, #code_to_decimal, #code_to_dictionary, #code_to_duration, #code_to_integer, #code_to_json, #code_to_list, #code_to_nothing, #code_to_parameter, #code_to_range, #code_to_string, #code_to_time, #code_truthy?, #eql?, #falsy?, #hash, #inspect, #multi_fetch, #nothing?, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s
Constructor Details
Instance Method Details
#call(**args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/code/object/boolean.rb', line 11 def call(**args) code_operator = args.fetch(:operator, nil).to_code code_arguments = args.fetch(:arguments, []).to_code code_value = code_arguments.code_first case code_operator.to_s when "&", "bitwise_and" sig(args) { Boolean } code_bitwise_and(code_value) when "^", "bitwise_xor" sig(args) { Boolean } code_bitwise_xor(code_value) when "|", "bitwise_or" sig(args) { Boolean } code_bitwise_or(code_value) else super end end |
#code_bitwise_and(other) ⇒ Object
31 32 33 34 35 |
# File 'lib/code/object/boolean.rb', line 31 def code_bitwise_and(other) code_other = other.to_code Boolean.new(raw & code_other.raw) end |
#code_bitwise_or(other) ⇒ Object
37 38 39 40 41 |
# File 'lib/code/object/boolean.rb', line 37 def code_bitwise_or(other) code_other = other.to_code Boolean.new(raw | code_other.raw) end |