Class: TextQuery
- Inherits:
-
Object
- Object
- TextQuery
- Defined in:
- lib/textquery/textquery.rb
Instance Method Summary (collapse)
- - (Object) accept(options = {}, &block)
- - (Object) eval(input, options = {}) (also: #match?)
-
- (TextQuery) initialize(query = '',, options = {})
constructor
A new instance of TextQuery.
- - (Object) parse(query)
- - (Object) terminal_failures
Constructor Details
- (TextQuery) initialize(query = '',, options = {})
A new instance of TextQuery
66 67 68 69 70 71 72 |
# File 'lib/textquery/textquery.rb', line 66 def initialize(query = '', = {}) @parser = TextQueryGrammarParser.new @query = nil () parse(query) if not query.empty? end |
Instance Method Details
- (Object) accept(options = {}, &block)
94 95 96 97 98 99 100 101 102 |
# File 'lib/textquery/textquery.rb', line 94 def accept( = {}, &block) () if not .empty? if @query @query.accept(&block) else raise TextQueryError, 'no query specified' end end |
- (Object) eval(input, options = {}) Also known as: match?
83 84 85 86 87 88 89 90 91 |
# File 'lib/textquery/textquery.rb', line 83 def eval(input, = {}) () if not .empty? if @query @query.eval(input, @options) else raise TextQueryError, 'no query specified' end end |
- (Object) parse(query)
74 75 76 77 78 79 80 81 |
# File 'lib/textquery/textquery.rb', line 74 def parse(query) query = query.mb_chars if RUBY_VERSION < '1.9' @query = @parser.parse(query) if not @query raise TextQueryError, "Could not parse query string '#{query}': #{@parser.terminal_failures.inspect}" end self end |
- (Object) terminal_failures
104 105 106 |
# File 'lib/textquery/textquery.rb', line 104 def terminal_failures @parser.terminal_failures end |