Sha256: 12f1fc62024718b16ec64ddb1d3734c538078c6da237f018cb31e3daea809fea

Contents?: true

Size: 1.4 KB

Versions: 13

Compression:

Stored size: 1.4 KB

Contents

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 FeduxOrg
  module Stdlib
    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 FeduxOrg::Stdlib::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
end

Version data entries

13 entries across 13 versions & 1 rubygems

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