Class: Query

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/query.rb

Constant Summary collapse

ATTRIBUTE_AND_VALUE_DIVIDERS =
/(?<!~)=/.freeze
VALUE_TO_LIST_DIVIDERS =
/(?<!~)&/.freeze
RepeatedFilter =
Class.new(StandardError)
Group =
Class.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Query

Returns a new instance of Query.



16
17
18
# File 'lib/query.rb', line 16

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



14
15
16
# File 'lib/query.rb', line 14

def argv
  @argv
end

Instance Method Details

#buildObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/query.rb', line 20

def build
  @build ||= argv.map.with_object([]) do |argument, query_options|
    query_element = query_element(argument)

    if query_options.find { |el| el[:attribute] == query_element[:attribute] }
      repeated_filter(query_element[:attribute])
    end

    query_options << query_element
  end
end