Sha256: dc369c45e4f88c24fd9b52e72213f49ced0a9e48ad0cebd3b618cff6df5c7b09
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
module Gamefic module Query class Text < Base def initialize *arguments arguments.each { |a| if (a.kind_of?(Symbol) or a.kind_of?(String)) and !a.to_s.end_with?('?') raise ArgumentError.new("Text query arguments can only be boolean method names (:method?) or regular expressions") end } super end def resolve(subject, token, continued: false) parts = token.split(Matchable::SPLIT_REGEXP) cursor = [] matches = [] i = 0 parts.each { |w| cursor.push w matches = cursor if accept?(cursor.join(' ')) i += 1 } if continued Matches.new([matches.join(' ')], matches.join(' '), parts[i..-1].join(' ')) else if matches.length == parts.length Matches.new([matches.join(' ')], matches.join(' '), '') else Matches.new([], '', parts.join(' ')) end end end def include?(subject, token) accept?(token) end def accept?(entity) return false unless entity.kind_of?(String) and !entity.empty? super end def precision 0 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gamefic-1.7.0 | lib/gamefic/query/text.rb |
gamefic-1.6.0 | lib/gamefic/query/text.rb |