Class: Amsi::AttributeParser::Boolean

Inherits:
Base
  • Object
show all
Defined in:
lib/amsi/attribute_parser/boolean.rb

Overview

Parse the response value of a boolean attribute

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Amsi::AttributeParser::Base

Instance Method Details

#parsetrue|false

Returns the parsed attribute value.

Returns:

  • (true|false)

    the parsed attribute value

Raises:



18
19
20
21
22
23
# File 'lib/amsi/attribute_parser/boolean.rb', line 18

def parse
  return true if TRUE_VALUES.include?(value)
  return false if FALSE_VALUES.include?(value)

  raise Error::InvalidResponse, "Invalid boolean response value: #{value}"
end