lib/search_lingo/token.rb in search_lingo-1.0.0.beta2 vs lib/search_lingo/token.rb in search_lingo-1.0.0.beta3
- old
+ new
@@ -1,23 +1,25 @@
require 'delegate'
+require 'search_lingo/constants'
module SearchLingo
class Token < DelegateClass(String)
- FORMAT = %r{\A(?:(\S+):\s*)?"?(.+?)"?\z}
+ STRUCTURE = /\A(?:(#{OPERATOR}):[[:space:]]*)?"?(.+?)"?\z/
def operator
- self[FORMAT, 1]
+ self[STRUCTURE, 1]
end
def term
- self[FORMAT, 2]
+ self[STRUCTURE, 2]
end
def compound?
!!operator
end
def inspect
- '#<%s %s operator=%s term=%s>' % [self.class, super, operator.inspect, term.inspect]
+ '#<%s String(%s) operator=%s term=%s>' %
+ [self.class, super, operator.inspect, term.inspect]
end
end
end