Class: TheCity::Metric

Inherits:
ApiObject show all
Defined in:
lib/api/metric.rb

Instance Attribute Summary

Attributes inherited from ApiObject

#error_messages, #marked_for_destruction

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • json_data (optional) (defaults to: nil)

    The object that has the data.

  • options (optional) (defaults to: {})

    Options for including more information.



27
28
29
30
31
32
# File 'lib/api/metric.rb', line 27

def initialize(json_data = nil, options = {}) 
  @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.

Parameters:

  • metric_id

    The ID of the user to load.



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_valuesMetricMeasurementValues

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

#measurementsMetricMeasurementList

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