Class WAZ::Tables::EdmTypeHelper
In: lib/waz/tables/edm_type_helper.rb
Parent: Object

Methods

Public Class methods

[Source]

    # File lib/waz/tables/edm_type_helper.rb, line 5
 5:         def parse_from(item)
 6:           return nil if !item.attributes['m:null'].nil? and item.attributes['m:null'] == 'true'
 7:           case item.attributes['m:type']
 8:             when 'Edm.Int16', 'Edm.Int32', 'Edm.Int64'
 9:               item.text.to_i
10:             when 'Edm.Single', 'Edm.Double'
11:               item.text.to_f
12:             when 'Edm.Boolean'
13:               item.text == 'true'
14:             when 'Edm.DateTime'
15:               Time.parse(item.text)
16:             when 'Edm.Binary'
17:               StringIO.new(Base64.decode64(item.text))
18:             else
19:               item.text
20:           end
21:         end

[Source]

    # File lib/waz/tables/edm_type_helper.rb, line 23
23:         def parse_to(item)
24:           case item.class.name
25:             when 'String'
26:               [item, 'Edm.String']
27:             when 'Fixnum'
28:               [item, 'Edm.Int32']
29:             when 'Float'
30:               [item, 'Edm.Double']
31:             when 'TrueClass', 'FalseClass'          
32:               [item, 'Edm.Boolean']
33:             when 'Time'
34:               [item.iso8601, 'Edm.DateTime']
35:             when 'File', 'StringIO'
36:               item.pos = 0
37:               [Base64.encode64(item.read), 'Edm.Binary']
38:             else
39:               [item, 'Edm.String']
40:           end
41:         end

[Validate]