Sha256: 0cedb8fe58753a56ec15b7c47ab27fb2434ad6a5a1d418b5e2f5c69ffbdcc0b3

Contents?: true

Size: 1020 Bytes

Versions: 14

Compression:

Stored size: 1020 Bytes

Contents

require 'fedux_org/stdlib/logic_converters/exceptions'

module FeduxOrg
  module Stdlib
    module LogicConverters
      class TrueFalseConverter

        # @param [true,false] value
        #   the logic value which should be converted
        # @return [String]
        #   the converted value: true => 'true', false => 'false', '' => nil
        #
        # @example Parse true
        #    converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
        #    converter.parse( true ) # 'true'
        #
        # @example Parse false
        #    converter = FeduxOrg::Stdlib::LogicConverters::OnOffConverter.new
        #    converter.parse( false ) # 'false'
        def parse( value )
          case value
          when true
            'true'
          when false
            'false'
          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

Version Path
fedux_org-stdlib-0.3.2 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.3.0 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.2.1 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.1.3 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.1.2 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.1.1 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.1.0 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.0.39 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.0.38 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.0.37 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.0.36 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.0.35 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.0.33 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb
fedux_org-stdlib-0.0.32 lib/fedux_org/stdlib/logic_converters/true_false_converter.rb