Class: Urbanairship::Devices::Attribute

Inherits:
Object
  • Object
show all
Includes:
Common, Loggable
Defined in:
lib/urbanairship/devices/attribute.rb

Constant Summary

Constants included from Common

Common::CONTENT_TYPE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

create_logger, logger, #logger

Methods included from Common

#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper

Constructor Details

#initialize(client: required('client')) ⇒ Attribute

Returns a new instance of Attribute.



13
14
15
# File 'lib/urbanairship/devices/attribute.rb', line 13

def initialize(client: required('client'))
    @client = client
end

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute.



8
9
10
# File 'lib/urbanairship/devices/attribute.rb', line 8

def attribute
  @attribute
end

#operatorObject

Returns the value of attribute operator.



8
9
10
# File 'lib/urbanairship/devices/attribute.rb', line 8

def operator
  @operator
end

#precisionObject

Returns the value of attribute precision.



8
9
10
# File 'lib/urbanairship/devices/attribute.rb', line 8

def precision
  @precision
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/urbanairship/devices/attribute.rb', line 8

def value
  @value
end

Instance Method Details

#date_attributeObject



43
44
45
46
47
48
49
50
# File 'lib/urbanairship/devices/attribute.rb', line 43

def date_attribute
    {
        'attribute': attribute,
        'operator': operator,
        'precision': precision,
        'value': value
    }
end

#number_attributeObject



27
28
29
30
31
32
33
# File 'lib/urbanairship/devices/attribute.rb', line 27

def number_attribute
    {
        'attribute': attribute,
        'operator': operator,
        'value': value
    }
end

#payloadObject



17
18
19
20
21
22
23
24
25
# File 'lib/urbanairship/devices/attribute.rb', line 17

def payload
    if precision
        date_attribute
    elsif value.is_a? String
        text_attribute
    elsif value.is_a? Integer 
        number_attribute
    end
end

#text_attributeObject



35
36
37
38
39
40
41
# File 'lib/urbanairship/devices/attribute.rb', line 35

def text_attribute
    {
        'attribute': attribute,
        'operator': operator,
        'value': value
    }
end