Class: OBIX::Types::Boolean

Inherits:
Type
  • Object
show all
Defined in:
lib/obix/types/boolean.rb

Instance Method Summary collapse

Methods inherited from Type

#initialize

Constructor Details

This class inherits a constructor from OBIX::Types::Type

Instance Method Details

#cast(value) ⇒ Object

Cast the given value to a boolean.

value - A string that is either “true” or “false”.

Returns a boolean.



11
12
13
14
15
16
17
18
19
20
# File 'lib/obix/types/boolean.rb', line 11

def cast value
  case value
  when "true"
    true
  when "false"
    false
  else
    raise StandardError, "Could not cast #{value} to a boolean"
  end
end