lib/triad.rb in triad-0.1.0 vs lib/triad.rb in triad-0.1.1

- old
+ new

@@ -17,19 +17,31 @@ @storage = {} end attr_reader :storage private :storage - def keys(arg) - with_interest(arg).map{|key, _, _| key } + def keys(arg=:__no_argument_given__) + if arg == :__no_argument_given__ + storage.keys + else + with_interest(arg).map{|key, _, _| key } + end end - def descriptors(arg) - with_interest(arg).map{|_, descriptor, _| descriptor } + def descriptors(arg=:__no_argument_given__) + if arg == :__no_argument_given__ + storage.map{|_,(descriptor,_)| descriptor } + else + with_interest(arg).map{|_, descriptor, _| descriptor } + end end - def values(arg) - with_interest(arg).map{|_, _, value| value } + def values(arg=:__no_argument_given__) + if arg == :__no_argument_given__ + storage.map{|_,(_,value)| value }.uniq + else + with_interest(arg).map{|_, _, value| value } + end end def <<(array) array_key = array.find{|item| item.is_a?(Symbol) } raise InvalidAddition if array.length != 3 || key_exists?(array_key)