Sha256: 00a873cbf86c8e05b63d62fe883c3bf9fd20569ade17daecd0e0e09c08f3fa98
Contents?: true
Size: 941 Bytes
Versions: 17
Compression:
Stored size: 941 Bytes
Contents
module Extlib # Simple set implementation # on top of Hash with merging support. # # In particular this is used to store # a set of callable actions of controller. class SimpleSet < Hash # @param arr<Array> Initial set values. # # @return <Array> The array the Set was initialized with def initialize(arr = []) arr.each {|x| self[x] = true} end # @param value<Object> Value to add to set. # # @return <TrueClass> def <<(value) self[value] = true end # @param arr<Array> Values to merge with set. # # @return <SimpleSet> The set after the Array was merged in. def merge(arr) super(arr.inject({}) {|s,x| s[x] = true; s }) end # @return <String> A human readable version of the set. def inspect "#<SimpleSet: {#{keys.map {|x| x.inspect}.join(", ")}}>" end # def to_a alias_method :to_a, :keys end # SimpleSet end # Merb
Version data entries
17 entries across 17 versions & 4 rubygems