Class: Icalendar::DowncasedHash
- Inherits:
-
Object
- Object
- Icalendar::DowncasedHash
- Defined in:
- lib/icalendar/downcased_hash.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key, &block) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #has_key?(key) ⇒ Boolean (also: #include?, #member?)
-
#initialize(base) ⇒ DowncasedHash
constructor
A new instance of DowncasedHash.
- #map(&block) ⇒ Object
- #merge(*other_hashes) ⇒ Object
- #merge!(*other_hashes) ⇒ Object
Constructor Details
#initialize(base) ⇒ DowncasedHash
Returns a new instance of DowncasedHash.
8 9 10 11 12 13 |
# File 'lib/icalendar/downcased_hash.rb', line 8 def initialize(base) @obj = Hash.new base.each do |key, value| self[key] = value end end |
Instance Method Details
#==(other) ⇒ Object
58 59 60 |
# File 'lib/icalendar/downcased_hash.rb', line 58 def ==(other) obj == Icalendar::DowncasedHash(other).obj end |
#[](key) ⇒ Object
19 20 21 |
# File 'lib/icalendar/downcased_hash.rb', line 19 def [](key) obj[key.to_s.downcase] end |
#[]=(key, value) ⇒ Object
15 16 17 |
# File 'lib/icalendar/downcased_hash.rb', line 15 def []=(key, value) obj[key.to_s.downcase] = value end |
#delete(key, &block) ⇒ Object
29 30 31 |
# File 'lib/icalendar/downcased_hash.rb', line 29 def delete(key, &block) obj.delete key.to_s.downcase, &block end |
#each(&block) ⇒ Object
50 51 52 |
# File 'lib/icalendar/downcased_hash.rb', line 50 def each(&block) obj.each &block end |
#empty? ⇒ Boolean
46 47 48 |
# File 'lib/icalendar/downcased_hash.rb', line 46 def empty? obj.empty? end |
#has_key?(key) ⇒ Boolean Also known as: include?, member?
23 24 25 |
# File 'lib/icalendar/downcased_hash.rb', line 23 def has_key?(key) obj.has_key? key.to_s.downcase end |
#map(&block) ⇒ Object
54 55 56 |
# File 'lib/icalendar/downcased_hash.rb', line 54 def map(&block) obj.map &block end |
#merge(*other_hashes) ⇒ Object
33 34 35 |
# File 'lib/icalendar/downcased_hash.rb', line 33 def merge(*other_hashes) Icalendar::DowncasedHash.new(obj).merge!(*other_hashes) end |
#merge!(*other_hashes) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/icalendar/downcased_hash.rb', line 37 def merge!(*other_hashes) other_hashes.each do |hash| hash.each do |key, value| self[key] = value end end self end |