Sha256: 62e5fd037fcf74a6203ce67e67863c785ac4631026ab4b99205a5aaed88ade39

Contents?: true

Size: 985 Bytes

Versions: 7

Compression:

Stored size: 985 Bytes

Contents

module ::Af::OptionParser
  class OptionGroup
    FACTORY_SETTABLES = [:title,
                         :priority,
                         :description,
                         :hidden,
                         :disabled]
    attr_accessor *FACTORY_SETTABLES
    attr_accessor :group_name

    def initialize(group_name, parameters = {})
      @group_name = group_name
      set_instance_variables(parameters)
    end

    #-------------------------
    # *** Instance Methods ***
    #+++++++++++++++++++++++++

    def set_instance_variables(parameters = {})
      parameters.select do |name,value|
        FACTORY_SETTABLES.include? name
      end.each do |name,value|
        instance_variable_set("@#{name}", value)
      end
    end

    def merge(that_option_group)
      FACTORY_SETTABLES.each do |name|
        if that_option_group.instance_variable_defined?("@#{name}")
          self.send("#{name}=", that_option_group.send(name))
        end
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fiksu-af-1.1.6 lib/fiksu-af/option_parser/option_group.rb
fiksu-af-1.1.5 lib/fiksu-af/option_parser/option_group.rb
fiksu-af-1.1.4 lib/fiksu-af/option_parser/option_group.rb
fiksu-af-1.1.3 lib/fiksu-af/option_parser/option_group.rb
fiksu-af-1.1.2 lib/fiksu-af/option_parser/option_group.rb
fiksu-af-1.1.1 lib/fiksu-af/option_parser/option_group.rb
fiksu-af-1.1.0 lib/fiksu-af/option_parser/option_group.rb