Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.14.4
Fetching contributors…

Cannot retrieve contributors at this time

31 lines (27 sloc) 0.537 kb
class OrderedOptions < Array #:nodoc:
def []=(key, value)
key = key.to_sym
if pair = find_pair(key)
pair.pop
pair << value
else
self << [key, value]
end
end
def [](key)
pair = find_pair(key.to_sym)
pair ? pair.last : nil
end
def method_missing(name, *args)
if name.to_s =~ /(.*)=$/
self[$1.to_sym] = args.first
else
self[name]
end
end
private
def find_pair(key)
self.each { |i| return i if i.first == key }
return false
end
end
Jump to Line
Something went wrong with that request. Please try again.