Class: TheCity::Metric
Instance Attribute Summary
Attributes inherited from ApiObject
#error_messages, #marked_for_destruction
Class Method Summary collapse
-
.load_by_id(metric_id) ⇒ Object
Loads the metric by the specified ID.
Instance Method Summary collapse
-
#initialize(json_data = nil, options = {}) ⇒ Metric
constructor
Constructor.
-
#measurement_values ⇒ MetricMeasurementValues
Measurement values list information.
-
#measurements ⇒ MetricMeasurementList
Measurement information.
Methods inherited from ApiObject
__tc_attributes, #delete, #initialize_from_json_object, #is_deleted?, #save, #set_attributes, tc_attr_accessor, #to_attributes
Constructor Details
#initialize(json_data = nil, options = {}) ⇒ Metric
Constructor.
27 28 29 30 31 32 |
# File 'lib/api/metric.rb', line 27 def initialize(json_data = nil, = {}) @writer_object = MetricWriter initialize_from_json_object(json_data) unless json_data.nil? @measurement_list = nil end |
Class Method Details
.load_by_id(metric_id) ⇒ Object
Loads the metric by the specified ID.
Returns a new TheCity::Metric object.
17 18 19 20 |
# File 'lib/api/metric.rb', line 17 def self.load_by_id(metric_id) metric_reader = MetricReader.new(metric_id) self.new(metric_reader.load_feed) end |
Instance Method Details
#measurement_values ⇒ MetricMeasurementValues
Measurement values list information.
51 52 53 54 55 56 57 |
# File 'lib/api/metric.rb', line 51 def measurement_values return @measurement_values unless @measurement_values.nil? return nil unless self.id @measurement_values = MetricMeasurementValues.new({:metric_id => self.id}) return @measurement_values end |
#measurements ⇒ MetricMeasurementList
Measurement information.
38 39 40 41 42 43 44 |
# File 'lib/api/metric.rb', line 38 def measurements return @measurement_list unless @measurement_list.nil? return nil unless self.id @measurement_list = MetricMeasurementList.new({:metric_id => self.id}) return @measurement_list end |