Class: Query

Inherits:
Object
  • Object
show all
Defined in:
lib/coding_challenge/commands/util/Query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_args) ⇒ Query

Returns a new instance of Query.



7
8
9
10
11
12
# File 'lib/coding_challenge/commands/util/Query.rb', line 7

def initialize(query_args)
  @product_type = query_args[0]
  @options = query_args.slice(1, query_args.length)
  @performed_at = nil
  @results = nil
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/coding_challenge/commands/util/Query.rb', line 4

def options
  @options
end

#performed_at=(value) ⇒ Object (writeonly)

Sets the attribute performed_at

Parameters:

  • value

    the value to set the attribute performed_at to.



5
6
7
# File 'lib/coding_challenge/commands/util/Query.rb', line 5

def performed_at=(value)
  @performed_at = value
end

#product_typeObject (readonly)

Returns the value of attribute product_type.



4
5
6
# File 'lib/coding_challenge/commands/util/Query.rb', line 4

def product_type
  @product_type
end

#resultsObject

Returns the value of attribute results.



4
5
6
# File 'lib/coding_challenge/commands/util/Query.rb', line 4

def results
  @results
end

Instance Method Details

#formatted_resultsObject



14
15
16
17
18
19
20
21
22
# File 'lib/coding_challenge/commands/util/Query.rb', line 14

def formatted_results
  results_str = "Performed At #{@performed_at}\n"
  results_str +=  "   Product Type Arg: #{@product_type}\n"
  results_str +=  "   Options Args: #{@options.join(', ')}\n"
  results_str +=  "   Results:\n"
  results_str +=  "      #{@results.join("\n      ")}"

  results_str
end