Class: Query
- Inherits:
-
Object
- Object
- Query
- Defined in:
- lib/coding_challenge/commands/util/Query.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#performed_at ⇒ Object
writeonly
Sets the attribute performed_at.
-
#product_type ⇒ Object
readonly
Returns the value of attribute product_type.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #formatted_results ⇒ Object
-
#initialize(query_args) ⇒ Query
constructor
A new instance of Query.
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
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/coding_challenge/commands/util/Query.rb', line 4 def @options end |
#performed_at=(value) ⇒ Object (writeonly)
Sets the attribute performed_at
5 6 7 |
# File 'lib/coding_challenge/commands/util/Query.rb', line 5 def performed_at=(value) @performed_at = value end |
#product_type ⇒ Object (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 |
#results ⇒ Object
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_results ⇒ Object
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 |