class Writer::OHash
Based on [ruby-talk:20551]. Updated to (hopefully) be 1.8 friendly.
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/pdf/writer/ohash.rb, line 16 def initialize(*args) @keys = [] super end
Public Instance Methods
[]=(key, val)
click to toggle source
Calls superclass method
# File lib/pdf/writer/ohash.rb, line 21 def []=(key, val) @keys << key unless has_key?(key) super end
Also aliased as: store
delete(key)
click to toggle source
Calls superclass method
# File lib/pdf/writer/ohash.rb, line 26 def delete(key) @keys.delete(key) if has_key?(key) super end
each() { |k, self| ... }
click to toggle source
# File lib/pdf/writer/ohash.rb, line 31 def each @keys.each { |k| yield k, self[k] } end
Also aliased as: each_pair
each_key() { |k| ... }
click to toggle source
# File lib/pdf/writer/ohash.rb, line 35 def each_key @keys.each { |k| yield k } end
each_value() { |self| ... }
click to toggle source
# File lib/pdf/writer/ohash.rb, line 39 def each_value @keys.each { |k| yield self[k] } end
first()
click to toggle source
# File lib/pdf/writer/ohash.rb, line 43 def first self[@keys[0]] end
first?(item)
click to toggle source
# File lib/pdf/writer/ohash.rb, line 51 def first?(item) self[@keys[0]] == item end
last()
click to toggle source
# File lib/pdf/writer/ohash.rb, line 47 def last self[@keys[-1]] end
last?(item)
click to toggle source
# File lib/pdf/writer/ohash.rb, line 55 def last?(item) self[@keys[-1]] == item end