Class: AMON::Entity

Inherits:
Document show all
Defined in:
lib/amon/entity.rb

Overview

An AMON entity, such as a house, business park, or building floor

Instance Attribute Summary

Attributes inherited from Document

#session

Attributes included from JSONHelper

#json

Instance Method Summary collapse

Methods inherited from Document

#==, #initialize

Constructor Details

This class inherits a constructor from AMON::Document

Instance Method Details

#completenessNumeric

Returns The all time completeness ratio (0 to 1) for the entity.

Returns:

  • (Numeric)

    The all time completeness ratio (0 to 1) for the entity



37
38
39
# File 'lib/amon/entity.rb', line 37

def completeness
  @completeness ||= get_completeness
end

#completeness_30dNumeric

Returns The 30 day completeness ratio (0 to 1) for the entity.

Returns:

  • (Numeric)

    The 30 day completeness ratio (0 to 1) for the entity



27
28
29
# File 'lib/amon/entity.rb', line 27

def completeness_30d
  @completeness_30d ||= get_completeness_30d
end

#completeness_6mNumeric

Returns The 6 month completeness ratio (0 to 1) for the entity.

Returns:

  • (Numeric)

    The 6 month completeness ratio (0 to 1) for the entity



32
33
34
# File 'lib/amon/entity.rb', line 32

def completeness_6m
  @completeness_6m ||= get_completeness_6m
end

#device_idsArray<String>

Returns The ids of all the devices associated with this entity.

Returns:

  • (Array<String>)

    The ids of all the devices associated with this entity



10
# File 'lib/amon/entity.rb', line 10

field :device_ids,          :name => 'deviceIds',                  :default => []

#devicesArray<Device>

Returns The devices associated with this entity.

Returns:

  • (Array<Device>)

    The devices associated with this entity



17
18
19
# File 'lib/amon/entity.rb', line 17

def devices
  @devices ||= device_ids.map { |device_id| session.device(id, device_id) }
end

#idString

Returns The id for this entity.

Returns:

  • (String)

    The id for this entity



7
# File 'lib/amon/entity.rb', line 7

field :id,                 :name => 'entityId'

#metering_point_idsArray<String>

TODO:

Rename to qualified_metering_point_ids

Returns The qualified ids of all the metering points associated with this entity.

Returns:

  • (Array<String>)

    The qualified ids of all the metering points associated with this entity



14
# File 'lib/amon/entity.rb', line 14

field :metering_point_ids, :name => 'qualifiedMeteringPointIds', :default => []

#metering_pointsArray<MeteringPoint>

Returns The metering points associated with the entity.

Returns:

  • (Array<MeteringPoint>)

    The metering points associated with the entity



22
23
24
# File 'lib/amon/entity.rb', line 22

def metering_points
  @metering_points ||= metering_point_ids.map { |id| session.metering_point(id) }
end