Class: Reading::Stats::Query
Overview
Gives statistics on an array of Items.
Instance Method Summary collapse
-
#initialize(input:, items:, result_formatters: {}) ⇒ Query
constructor
A new instance of Query.
-
#result ⇒ Object
Parses the query and returns the result.
Constructor Details
#initialize(input:, items:, result_formatters: {}) ⇒ Query
Returns a new instance of Query.
18 19 20 21 22 23 |
# File 'lib/reading/stats/query.rb', line 18 def initialize(input:, items:, result_formatters: {}) @input = input @items = items @result_formatters = result_formatters @pastel = Pastel.new end |
Instance Method Details
#result ⇒ Object
Parses the query and returns the result.
27 28 29 30 31 32 33 34 |
# File 'lib/reading/stats/query.rb', line 27 def result filtered_items = Stats::Filter.filter(input, items) grouped_items = Grouping.group(input, filtered_items) Operation.execute(input, grouped_items, result_formatters || {}) rescue Reading::Error => e raise e.class, pastel.bright_red(e.) end |