Module: Yarbf::BooleanJudge

Included in:
BfInterpreter
Defined in:
lib/yarbf.rb

Instance Method Summary collapse

Instance Method Details

#is_boolean?(obj, &block) ⇒ Boolean

Determines and returns whether an object is a boolean value.

obj

An #Object.

&block

A block to call when true.

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/yarbf.rb', line 19

def is_boolean?(obj, &block)
  result = [true, false].include?(obj)
  yield if result && !block.nil?
  result
end

#not_boolean?(obj, &block) ⇒ Boolean

Determines and returns whether an object is not a boolean value.

obj

An #Object.

&block

A block to call when true.

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/yarbf.rb', line 31

def not_boolean?(obj, &block)
  result = [true, false].include?(obj)
  yield unless result || block.nil?
  result
end