Module: CloudConnect::Units

Included in:
Client
Defined in:
lib/cloud_connect/client/units.rb

Defined Under Namespace

Modules: UnitMethods

Instance Method Summary (collapse)

Instance Method Details

- (Array<Hashie::Mash>) find_units(modids)

Search for a specific unit knowing it's modid

Examples:

find_unit("*3216*")

See Also:



31
32
33
34
35
36
# File 'lib/cloud_connect/client/units.rb', line 31

def find_units(modids)
  # TODO: Rename unit_search?
  units = connection.get(connection.build_url("units/search", :modids => modids)).body
  units.map!{|hash| hash.values.first}
  units.each{|u| u.extend UnitMethods; u._cloud_connect = self;}
end

- (Hashie::Mash) unit(unit_id = nil, opts = {})

Return information about a specific unit

Options Hash (opts):

  • :ret (String) — default: 'id, lat, long, time'

    Select attributes to fetch

  • :fieldids (String)

    List of field ids

  • :unknow (String)

    Allow unknown position



46
47
48
49
50
51
# File 'lib/cloud_connect/client/units.rb', line 46

def unit(unit_id=nil, opts = {})
  units = connection.get(connection.build_url("units", opts.merge(:unitids => unit_id))).body
  units.map!{|hash| hash.values.first}
  units.each{|u| u.extend UnitMethods; u._cloud_connect = self;}
  units.first
end

- (Array<Hashie::Mash>) units(opts = {})

Returns all units that match parameters provided in +opts+ list (if +opts+ is provided)

Options Hash (opts):

  • :ret (String) — default: 'id, lat, long, time'

    Select attributes to fetch

  • :unitids (String)

    List of unit ids

  • :fieldids (String)

    List of field ids

  • :unknow (String)

    Allow unknown position

  • :id_min (Integer)

    Minimum ID

  • :id_max (Integer)

    Maximum ID

  • :limit (Integer)

    Number of elements to fetch (default 25

See Also:



17
18
19
20
21
# File 'lib/cloud_connect/client/units.rb', line 17

def units(opts = {})
  units = connection.get(connection.build_url("units", opts)).body
  units.map!{|hash| hash.values.first}
  units.each{|u| u.extend UnitMethods; u._cloud_connect = self;}
end