Class: Set

Inherits:
Object
  • Object
show all
Defined in:
lib/distorted/monkey_business/set.rb

Overview

Override Set.to_hash to complement Ruby::YAML’s Set implementation, where the YAML Set syntax returns a Hash with all-nil values, at least without some decorator sugar in the YAML itself: rhnh.net/2011/01/31/yaml-tutorial/

Since Set is implemented using a Hash internally I think it makes more sense for Set.to_hash to return a Hash with all-nil values with keys matching the contents of the original Set.

Instance Method Summary collapse

Instance Method Details

#to_hashObject



12
13
14
# File 'lib/distorted/monkey_business/set.rb', line 12

def to_hash
  Hash[self.map { |s| [s, nil] }]
end