Sha256: 8a34953e0682cee93b4ee70c7fdb89b038525d18bd70fbd7cde0a30278b5a318

Contents?: true

Size: 726 Bytes

Versions: 5

Compression:

Stored size: 726 Bytes

Contents

require 'ostruct'
module Bioinform
  module Parameters
    def self.included(base)
      base.extend(ClassMethods)
    end
    module ClassMethods
      def make_parameters(*params)
        params.each do |param|
          define_method(param){ parameters.send(param) }
          define_method("#{param}="){|new_value| parameters.send("#{param}=", new_value) }
        end
      end
    end
    def parameters; @parameters ||= OpenStruct.new; end
    def set_parameters(hsh)
      hsh.each{|k,v| send("#{k}=", v) }
      self
    end
    # return hash of parameters
    def get_parameters
      @parameters.marshal_dump
    end
    def parameter_defined?(param_name)
      get_parameters.has_key?(param_name)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bioinform-0.1.17 lib/bioinform/support/parameters.rb
bioinform-0.1.16 lib/bioinform/support/parameters.rb
bioinform-0.1.15 lib/bioinform/support/parameters.rb
bioinform-0.1.14 lib/bioinform/support/parameters.rb
bioinform-0.1.13 lib/bioinform/support/parameters.rb