Class: Katalyst::Tables::Collection::Query::ValueParser

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

Direct Known Subclasses

ArrayValueParser, SingleValueParser

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, start:) ⇒ ValueParser

Returns a new instance of ValueParser.



10
11
12
13
# File 'app/models/concerns/katalyst/tables/collection/query/value_parser.rb', line 10

def initialize(key:, start:)
  @key = key
  @start = start
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



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

def key
  @key
end

#queryObject

Returns the value of attribute query.



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

def query
  @query
end

Instance Method Details

#literal?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/models/concerns/katalyst/tables/collection/query/value_parser.rb', line 15

def literal?
  false
end

#rangeObject



23
24
25
# File 'app/models/concerns/katalyst/tables/collection/query/value_parser.rb', line 23

def range
  @start..@end
end

#skip_whitespaceObject



41
42
43
# File 'app/models/concerns/katalyst/tables/collection/query/value_parser.rb', line 41

def skip_whitespace
  query.scan(/\s+/)
end

#tagged?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/models/concerns/katalyst/tables/collection/query/value_parser.rb', line 19

def tagged?
  true
end

#take_quoted_valueObject



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

def take_quoted_value
  return unless query.scan(/"([^"]*)"/)

  self.value, = query.values_at(1)
end

#take_unquoted_valueObject



33
34
35
36
37
38
39
# File 'app/models/concerns/katalyst/tables/collection/query/value_parser.rb', line 33

def take_unquoted_value
  # note, we allow unquoted values to begin with a " so that partial
  # inputs can be accepted
  return unless query.scan(/"?([^ \],]*)/)

  self.value, = query.values_at(1)
end