Class: PDF::Writer::OHash
- Inherits:
-
Hash
- Object
- Hash
- PDF::Writer::OHash
- Defined in:
- lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb
Overview
Based on [ruby-talk:20551]. Updated to (hopefully) be 1.8 friendly.
Instance Method Summary collapse
- #[]=(key, val) ⇒ Object
- #delete(key) ⇒ Object
- #each ⇒ Object
- #each_key ⇒ Object
- #each_pair ⇒ Object
- #each_value ⇒ Object
- #first ⇒ Object
- #first?(item) ⇒ Boolean
-
#initialize(*args) ⇒ OHash
constructor
A new instance of OHash.
- #last ⇒ Object
- #last?(item) ⇒ Boolean
- #store ⇒ Object
Constructor Details
#initialize(*args) ⇒ OHash
Returns a new instance of OHash.
16 17 18 19 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 16 def initialize(*args) @keys = [] super end |
Instance Method Details
#[]=(key, val) ⇒ Object
21 22 23 24 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 21 def []=(key, val) @keys << key unless has_key?(key) super end |
#delete(key) ⇒ Object
26 27 28 29 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 26 def delete(key) @keys.delete(key) if has_key?(key) super end |
#each ⇒ Object
31 32 33 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 31 def each @keys.each { |k| yield k, self[k] } end |
#each_key ⇒ Object
35 36 37 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 35 def each_key @keys.each { |k| yield k } end |
#each_pair ⇒ Object
14 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 14 alias_method :each_pair, :each |
#each_value ⇒ Object
39 40 41 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 39 def each_value @keys.each { |k| yield self[k] } end |
#first ⇒ Object
43 44 45 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 43 def first self[@keys[0]] end |
#first?(item) ⇒ Boolean
51 52 53 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 51 def first?(item) self[@keys[0]] == item end |
#last ⇒ Object
47 48 49 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 47 def last self[@keys[-1]] end |
#last?(item) ⇒ Boolean
55 56 57 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 55 def last?(item) self[@keys[-1]] == item end |
#store ⇒ Object
13 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/ohash.rb', line 13 alias_method :store, :[]= |