class FeduxOrgStdlib::LogicConverters::OnOffConverter

Convert on/off to true/false

Public Instance Methods

parse(value) click to toggle source

@param [true,false] value

the logic value which should be converted

@return [String]

the converted value: true => on, false => off, '' => nil

@example Parse true

converter = FeduxOrgStdlib::LogicConverters::OnOffConverter.new
converter.parse( true ) # on

@example Parse false

converter = FeduxOrgStdlib::LogicConverters::OnOffConverter.new
converter.parse( false ) # off
# File lib/fedux_org_stdlib/logic_converters/on_off_converter.rb, line 22
def parse(value)
  case value
  when true
    'on'
  when false
    'off'
  when ''
    nil
  else
    fail FeduxOrgStdlib::LogicConverters::Exceptions::InvalidValue, "Unknown logic value \"#{value}\"."
  end
end