Class: ConvenientService::Utils::Bool::ToBool

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/bool/to_bool.rb

Overview

Converts objects to boolean. Implementation is very basic just to serve the need of this library. More comprehensive solution can be found in Rails, wannabe_bool, etc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(object) ⇒ void

Parameters:

  • object (Object)

    Can be any type.



24
25
26
# File 'lib/convenient_service/utils/bool/to_bool.rb', line 24

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



18
19
20
# File 'lib/convenient_service/utils/bool/to_bool.rb', line 18

def object
  @object
end

Instance Method Details

#callBoolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/convenient_service/utils/bool/to_bool.rb', line 31

def call
  !!object
end