BlankSlate
Basically an Set, but with Order, ain't that obivous?
# File lib/ramaze/snippets/ordered_set.rb, line 8 def self.[](*args) new(*args) end
Create new instances, optionally pass the first set
# File lib/ramaze/snippets/ordered_set.rb, line 13 def initialize(*args) if args.size == 1 @set = args.shift else @set = *args end @set ||= [] @set = [@set] unless ::Array === @set @set.uniq! end
# File lib/ramaze/snippets/ordered_set.rb, line 34 def []= *args @set.map! do |e| if ::Array === args.last args.last.include?(e) ? nil : e else args.last == e ? nil : e end end @set.__send__(:[]=, *args) @set.compact! end
Delegate everything, but controlled, keep elements unique. Warning, this is not really atomic.
# File lib/ramaze/snippets/ordered_set.rb, line 48 def method_missing(meth, *args, &block) @set.__send__(meth, *args, &block) end
[Validate]
Generated with the Darkfish Rdoc Generator 2.