Class: Boson::IndifferentAccessHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/boson/option_parser.rb

Overview

Simple Hash with indifferent fetching and storing using symbol or string keys. Other actions such as merging should assume symbolic keys. Used by OptionParser.

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ IndifferentAccessHash

:stopdoc:



6
7
8
9
# File 'lib/boson/option_parser.rb', line 6

def initialize(hash={})
  super()
  hash.each {|k,v| self[k] = v }
end

Instance Method Details

#[](key) ⇒ Object



11
12
13
# File 'lib/boson/option_parser.rb', line 11

def [](key)
  super convert_key(key)
end

#[]=(key, value) ⇒ Object



15
16
17
# File 'lib/boson/option_parser.rb', line 15

def []=(key, value)
  super convert_key(key), value
end

#values_at(*indices) ⇒ Object



19
20
21
# File 'lib/boson/option_parser.rb', line 19

def values_at(*indices)
  indices.collect { |key| self[convert_key(key)] }
end