Class: Katalyst::Tables::Collection::Query::SingleValueParser

Inherits:
ValueParser
  • Object
show all
Defined in:
app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb

Instance Attribute Summary

Attributes inherited from ValueParser

#key, #query

Instance Method Summary collapse

Methods inherited from ValueParser

#literal?, #range, #skip_whitespace, #tagged?, #take_quoted_value, #take_unquoted_value

Constructor Details

#initializeSingleValueParser

Returns a new instance of SingleValueParser.



8
9
10
11
12
# File 'app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb', line 8

def initialize(...)
  super

  @value = nil
end

Instance Method Details

#parse(query) ⇒ Object

Parameters:

  • query (StringScanner)


15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb', line 15

def parse(query)
  @query = query

  @value_start = query.charpos

  take_quoted_value || take_unquoted_value

  @end = query.charpos

  self
end

#valueObject



27
28
29
# File 'app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb', line 27

def value
  @value
end

#value=(value) ⇒ Object



31
32
33
# File 'app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb', line 31

def value=(value)
  @value = value
end

#value_at(position) ⇒ Object



35
36
37
# File 'app/models/concerns/katalyst/tables/collection/query/single_value_parser.rb', line 35

def value_at(position)
  @value if (@value_start..@end).cover?(position)
end