class Nephos::Params
Params
to a hash, where every elements are accessibles via a stringified key so, even if the entry was added with the key :KEY, it will be accessible via a string equivalent to :key.to_s
param["key"] == param[:key]
Every methods present in {Hash} are usable in {Param}.
Public Class Methods
new(hash={})
click to toggle source
@param hash [Hash] hash containing the parameters
# File lib/nephos-server/params.rb, line 14 def initialize(hash={}) raise ArgumentError, "the first argument must be a Hash" unless hash.is_a? Hash @hash = Hash[hash.map{|k,v| [k.to_s, v]}] end
Public Instance Methods
[](i)
click to toggle source
# File lib/nephos-server/params.rb, line 23 def [] i @hash[i.to_s] end
[]=(i, v)
click to toggle source
# File lib/nephos-server/params.rb, line 27 def []= i, v @hash[i.to_s] = v.to_s end
method_missing(m, *a)
click to toggle source
# File lib/nephos-server/params.rb, line 19 def method_missing m, *a @hash.send(m, *(a.map(&:to_s))) end
to_h()
click to toggle source
# File lib/nephos-server/params.rb, line 31 def to_h return @hash end
Also aliased as: to_hash
to_s()
click to toggle source
# File lib/nephos-server/params.rb, line 36 def to_s return to_h.to_s end