Sha256: 0f5e20d56ecad2682a626de61a328834b58f13e9dd6399b4b01ce0e58c2a3f3a
Contents?: true
Size: 1009 Bytes
Versions: 14
Compression:
Stored size: 1009 Bytes
Contents
require 'fedux_org/stdlib/logic_converters/exceptions' module FeduxOrg module Stdlib module LogicConverters class OnOffConverter # @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 = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new # converter.parse( true ) # on # # @example Parse false # converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new # converter.parse( false ) # off # def parse( value ) case value when true 'on' when false 'off' 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