Class: AMEE::Admin::ReturnValueDefinitionList

Inherits:
Collection
  • Object
show all
Defined in:
lib/amee/v3/return_value_definition.rb

Instance Attribute Summary

Attributes inherited from Collection

#connection, #doc, #json, #pager, #response

Instance Method Summary collapse

Methods inherited from Collection

#each_page, #each_page_without_v3, #fetch, #fetch_without_v3, #parse_page, #v3

Methods included from ParseHelper

#load_xml_doc, #node_value, #xmlpathpreamble

Constructor Details

#initialize(connection, uid, options = {}) ⇒ ReturnValueDefinitionList

TODO this class does not yet page through multiple pages



9
10
11
12
13
# File 'lib/amee/v3/return_value_definition.rb', line 9

def initialize(connection,uid,options={})
  @uid=uid
  @use_v3_connection=true
  super(connection,options)
end

Instance Method Details

#collectionpathObject



17
18
19
# File 'lib/amee/v3/return_value_definition.rb', line 17

def collectionpath
  "/#{AMEE::Connection.api_version}/definitions/#{@uid}/returnvalues;full"
end

#jsoncollectorObject



21
22
23
# File 'lib/amee/v3/return_value_definition.rb', line 21

def jsoncollector
  @doc['returnValueDefinitions']
end

#klassObject



14
15
16
# File 'lib/amee/v3/return_value_definition.rb', line 14

def klass
  ReturnValueDefinition
end

#parse_json(p) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/amee/v3/return_value_definition.rb', line 28

def parse_json(p)
  data = {}
  data[:itemdefuid] = @uid
  data[:uid] = p['uid']
  data[:name] = p['type']
  data[:unit] = p['unit']
  data[:perunit] = p['perunit']
  data[:valuetype] = p['valueDefinition']['valueType']
  data
end

#parse_xml(p) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/amee/v3/return_value_definition.rb', line 38

def parse_xml(p)
  data = {}
  data[:itemdefuid] = @uid
  data[:uid] = x '@uid',:doc => p
  data[:name] = x 'Type',:doc => p  || data[:uid]
  data[:unit] = x 'Unit',:doc => p
  data[:perunit] = x 'PerUnit',:doc => p
  data
end

#xmlcollectorpathObject



24
25
26
# File 'lib/amee/v3/return_value_definition.rb', line 24

def xmlcollectorpath
  '/Representation/ReturnValueDefinitions/ReturnValueDefinition'
end