Class: Medic::StatisticsCollectionQueryBuilder
- Inherits:
-
Object
- Object
- Medic::StatisticsCollectionQueryBuilder
- Includes:
- Anchor, Interval, Predicate, StatisticsOptions, Types
- Defined in:
- lib/medic/statistics_collection_query_builder.rb
Constant Summary
Constants included from Interval
Constants included from Anchor
Constants included from StatisticsOptions
Medic::StatisticsOptions::STATISTICS_OPTIONS
Constants included from QueryOptions
Constants included from Types
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #initial_results_handler ⇒ Object
- #initial_results_handler=(callback = Proc.new) ⇒ Object
-
#initialize(args = {}) ⇒ StatisticsCollectionQueryBuilder
constructor
A new instance of StatisticsCollectionQueryBuilder.
- #statistics_update_handler ⇒ Object
- #statistics_update_handler=(callback = Proc.new) ⇒ Object
Methods included from Interval
Methods included from Anchor
Methods included from StatisticsOptions
#options_for_stat_query, #statistics_option
Methods included from Predicate
Methods included from QueryOptions
Methods included from Types
#object_type, #type_identifier
Constructor Details
#initialize(args = {}) ⇒ StatisticsCollectionQueryBuilder
Returns a new instance of StatisticsCollectionQueryBuilder.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/medic/statistics_collection_query_builder.rb', line 12 def initialize(args={}) @params = args @query = HKStatisticsCollectionQuery.alloc.initWithQuantityType(object_type(args[:type]), quantitySamplePredicate: predicate(args), options: (args[:options]), anchorDate: anchor_for_symbol(args[:anchor_date] || args[:anchor] || args[:date] || NSDate.date), intervalComponents: interval(args[:interval_components] || args[:interval]) ) if block_given? handler = Proc.new @query.initialResultsHandler = handler @query.statisticsUpdateHandler = Proc.new{|q,_,r,e| handler.call(q,r,e)} if args[:update] == true end @query.statisticsUpdateHandler = args[:update] if args[:update].is_a?(Proc) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/medic/statistics_collection_query_builder.rb', line 3 def params @params end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
4 5 6 |
# File 'lib/medic/statistics_collection_query_builder.rb', line 4 def query @query end |
Instance Method Details
#initial_results_handler ⇒ Object
28 29 30 |
# File 'lib/medic/statistics_collection_query_builder.rb', line 28 def initial_results_handler @query.initialResultsHandler end |
#initial_results_handler=(callback = Proc.new) ⇒ Object
32 33 34 |
# File 'lib/medic/statistics_collection_query_builder.rb', line 32 def initial_results_handler=(callback=Proc.new) @query.initialResultsHandler = callback end |
#statistics_update_handler ⇒ Object
36 37 38 |
# File 'lib/medic/statistics_collection_query_builder.rb', line 36 def statistics_update_handler @query.statisticsUpdateHandler end |
#statistics_update_handler=(callback = Proc.new) ⇒ Object
40 41 42 |
# File 'lib/medic/statistics_collection_query_builder.rb', line 40 def statistics_update_handler=(callback=Proc.new) @query.statisticsUpdateHandler = callback end |