]> git.cworth.org Git - sup/blobdiff - lib/sup/util.rb
add gpg interface to all outgoing messages (but no implementation yet)
[sup] / lib / sup / util.rb
index cc15803b1ddb4ed9a6b4d91d7c6ceb935e26a9e5..e2b82e1f6cbbeeb321654c456b4a6d339fe2a838 100644 (file)
@@ -577,23 +577,26 @@ end
 class OrderedHash < Hash
   alias_method :store, :[]=
   alias_method :each_pair, :each
+  attr_reader :keys
 
-  def initialize
+  def initialize *a
     @keys = []
+    a.each { |k, v| self[k] = v }
   end
 
-  def []=(key, val)
+  def []= key, val
     @keys << key unless member?(key)
     super
   end
 
-  def delete(key)
-    @keys.delete(key)
+  def values; keys.map { |k| self[k] } end
+  def index key; @keys.index key end
+
+  def delete key
+    @keys.delete key
     super
   end
 
-  def each
-    @keys.each { |k| yield k, self[k] }
-  end
+  def each; @keys.each { |k| yield k, self[k] } end
 end