Sha256: 287e28884c2a0972a0f0b8c0b1a6805db2a6661ac7f71b0b4e68bdd53a928666
Contents?: true
Size: 988 Bytes
Versions: 14
Compression:
Stored size: 988 Bytes
Contents
require 'fedux_org/stdlib/logic_converters/exceptions' module FeduxOrg module Stdlib module LogicConverters class YNConverter # @param [true,false] value # the logic value which should be converted # @return [String] # the converted value: true => y, false => n, '' => nil # # @example Parse true # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new # converter.parse( true ) # 'y' # # @example Parse false # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new # converter.parse( false ) # 'n' def parse( value ) case value when true 'y' when false 'n' when '' nil else raise FeduxOrg::Stdlib::LogicConverters::Exceptions::InvalidValue, "Unknown logic value \"#{value}\"." end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems