Sha256: 6d2f6139eba1e82b7dd1a3d35dd8dff4fb95eb1ee1f7dd46d405d74e80ff03ed

Contents?: true

Size: 947 Bytes

Versions: 64

Compression:

Stored size: 947 Bytes

Contents

# encoding: utf-8
require 'fedux_org_stdlib/logic_converters/exceptions'

module FeduxOrgStdlib
  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 = FeduxOrgStdlib::LogicConverters::OnOffConverter.new
      #    converter.parse( true ) # on
      #
      # @example Parse false
      #    converter = FeduxOrgStdlib::LogicConverters::OnOffConverter.new
      #    converter.parse( false ) # off
      #   
      def parse( value )
        case value
        when true
          'on'
        when false
          'off'
        when ''
          nil
        else
          raise FeduxOrgStdlib::LogicConverters::Exceptions::InvalidValue, "Unknown logic value \"#{value}\"."
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.7.21 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.20 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.19 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.18 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.17 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.16 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.15 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.14 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.12 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.11 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.10 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.8 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.7 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.6 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.5 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.4 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.3 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.2 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.1 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb
fedux_org-stdlib-0.7.0 lib/fedux_org_stdlib/logic_converters/on_off_converter.rb