Class: TheCity::MetricMeasurementValues

Inherits:
ApiObject
  • Object
show all
Includes:
Enumerable
Defined in:
lib/api/metric_measurement_values.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(options = {}) ⇒ MetricMeasurementValues

Constructor.

Options:

:metric_id - The ID of the metric to load the measurements values for. (required)
:reader - The Reader to use to load the data.

Examples:

MetricMeasurementValues.new({:metric_id => 12345})

Parameters:

  • options (defaults to: {})

    A hash of options for loading the list.



32
33
34
35
# File 'lib/api/metric_measurement_values.rb', line 32

def initialize(options = {})
  options[:reader] = TheCity::MetricMeasurementValuesReader.new(options) if options[:reader].nil?
  @json_data = options[:reader].load_feed 
end

Class Method Details

.load_by_id(metric_id) ⇒ Object

Loads the metric measurement values by the specified metric ID.

Returns a new TheCity::Metric object.

Parameters:

  • metric_id

    The ID of the user to load.



14
15
16
17
# File 'lib/api/metric_measurement_values.rb', line 14

def self.load_by_id(metric_id)
  metric_reader = MetricReader.new(metric_id)
  self.new(metric_reader.load_feed)
end

Instance Method Details

#[](index) ⇒ Object

Get the specified account admin privilege.

Parameters:

  • index

    The index of the admin privilege to get.

Returns:

  • Number



42
43
44
# File 'lib/api/metric_measurement_values.rb', line 42

def [](index)
  @json_data['values'][index] if @json_data['values'][index]
end

#each(&block) ⇒ Object

This method is needed for Enumerable.



48
49
50
# File 'lib/api/metric_measurement_values.rb', line 48

def each &block
  @json_data['values'].each{ |value| yield(value) }
end

#empty?Boolean

Checks if the list is empty.

Returns:

  • (Boolean)

    True on empty, false otherwise.



58
59
60
# File 'lib/api/metric_measurement_values.rb', line 58

def empty?
  @json_data['values'].empty?
end