Parent

Class/Module Index [+]

Quicksearch

Github::CoreExt::OrderedHash

Attributes

order[RW]

Public Class Methods

[](*args) click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 12
def [](*args)
  hsh = OrderedHash.new
  if Hash == args[0]
    hsh.replace args[0]
  elsif (args.size % 2) != 0
    pp args
    raise ArgumentError, "odd number of elements for Hash"
  else
    0.step(args.size - 1, 2) do |a|
      b = a + 1
      hsh[args[a]] = args[b]
    end
  end
  hsh
end
new(*args, &block) click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 29
def initialize(*args, &block)
  super
  @order = []
end

Public Instance Methods

==(hsh2) click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 39
def ==(hsh2)
  return false if @order != hsh2.order
  super hsh2
end
[]=(key, value) click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 34
def []=(key, value)
  @order.push key unless member?(key)
  super key, value
end
__class__() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 99
def __class__
  OrderedHash
end
class() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 95
def class
  Hash
end
clear() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 44
def clear
  @order = []
  super
end
delete(key) click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 49
def delete(key)
  @order.delete key
  super
end
delete_if() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 70
def delete_if
  @order.clone.each { |k| delete k if yield }
  self
end
each() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 64
def each
  @order.each { |k| yield k, self[k] }
  self
end
Also aliased as: each_pair
each_key() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 54
def each_key
  @order.each { |k| yield k }
  self
end
each_pair() click to toggle source
Alias for: each
each_value() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 59
def each_value
  @order.each { |k| yield self[k] }
  self
end
keys() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 81
def keys
  @order
end
replace(hsh2) click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 85
def replace(hsh2)
  @order = hsh2.keys
  super hsh2
end
shift() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 90
def shift
  key = @order.first
  key ? [key, delete(key)] : super
end
values() click to toggle source
# File lib/github_api/core_ext/ordered_hash.rb, line 75
def values
  ary = []
  @order.each { |k| ary.push self[k] }
  ary
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.