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.6.29 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.28 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.27 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.26 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.25 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.23 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.22 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.21 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.20 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.18 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.17 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.16 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.15 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.14 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.13 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.12 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.11 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.9 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.8 lib/fedux_org_stdlib/logic_converters/logic_converter.rb
fedux_org-stdlib-0.6.7 lib/fedux_org_stdlib/logic_converters/logic_converter.rb