Sha256: dddbc3d1e22efbe0a3c2aa24c9fa318166e8c6ce050158eb33eb289d0f5df373

Contents?: true

Size: 1.35 KB

Versions: 64

Compression:

Stored size: 1.35 KB

Contents

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

require 'fedux_org_stdlib/logic_converters/on_off_converter'
require 'fedux_org_stdlib/logic_converters/true_false_converter'
require 'fedux_org_stdlib/logic_converters/yes_no_converter'
require 'fedux_org_stdlib/logic_converters/y_n_converter'

module FeduxOrgStdlib
  module LogicConverters
    class LogicConverter

      # @param [String, Symbol] type (true_false, yes_no, on_off)
      #   choose the type of converter which should be used 
      def initialize(type)
        @converter = case type.to_s
                     when 'true_false'
                       TrueFalseConverter.new
                     when 'yes_no' 
                       YesNoConverter.new
                     when 'on_off' 
                       OnOffConverter.new
                     when 'y_n' 
                       YNConverter.new
                     else
                       raise FeduxOrgStdlib::LogicConverters::Exceptions::InvalidType, "Unknown type \"#{type}\" for logic converter. Valid types are \"true_false\", \"yes_no\" or \"on_off\"."
                     end
      end

      # @param [true,false] value
      #   the logic value which should be converted
      # @return [String]
      #   the converted value
      def parse( value )
        @converter.parse( value )
      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/logic_converter.rb
fedux_org-stdlib-0.7.20 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.19 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.18 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.17 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.16 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.15 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.14 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.12 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.11 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.10 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.8 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.7 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.6 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.5 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.4 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.3 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.2 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.1 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.7.0 lib/fedux_org_stdlib/logic_converters/logic_converter.rb