Class: Appydave::Tools::RandomContext::QueryEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/appydave/tools/random_context/query_entry.rb

Overview

Represents one entry in the random-queries.yml config file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ QueryEntry

Returns a new instance of QueryEntry.



10
11
12
13
14
15
# File 'lib/appydave/tools/random_context/query_entry.rb', line 10

def initialize(data)
  @label = data['label']
  @command = data['command']
  @min_results = data.fetch('min_results', 1)
  @max_results = data.fetch('max_results', 15)
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



8
9
10
# File 'lib/appydave/tools/random_context/query_entry.rb', line 8

def command
  @command
end

#labelObject (readonly)

Returns the value of attribute label.



8
9
10
# File 'lib/appydave/tools/random_context/query_entry.rb', line 8

def label
  @label
end

#max_resultsObject (readonly)

Returns the value of attribute max_results.



8
9
10
# File 'lib/appydave/tools/random_context/query_entry.rb', line 8

def max_results
  @max_results
end

#min_resultsObject (readonly)

Returns the value of attribute min_results.



8
9
10
# File 'lib/appydave/tools/random_context/query_entry.rb', line 8

def min_results
  @min_results
end

Instance Method Details

#good_count?(count) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/appydave/tools/random_context/query_entry.rb', line 17

def good_count?(count)
  count.between?(min_results, max_results)
end