lib/picky/query/tokens.rb in picky-4.5.9 vs lib/picky/query/tokens.rb in picky-4.5.10
- old
+ new
@@ -6,11 +6,11 @@
# This class primarily handles switching through similar token constellations.
#
class Tokens
- attr_reader :ignore_unassigned
+ attr_reader :tokens, :ignore_unassigned
# Basically delegates to its internal tokens array.
#
self.delegate *[Enumerable.instance_methods, :slice!, :[], :uniq!, :last, :reject!, :length, :size, :empty?, :each, :exit, { :to => :@tokens }].flatten
@@ -72,12 +72,22 @@
#
#
def originals
@tokens.map(&:original)
end
-
+
+ #
+ #
def == other
self.tokens == other.tokens
+ end
+
+ # Non destructive.
+ #
+ # TODO Make destructive?
+ #
+ def + other
+ self.class.new (@tokens + other.tokens), (self.ignore_unassigned || other.ignore_unassigned)
end
# Just join the token original texts.
#
def to_s
\ No newline at end of file