Class: JPush::TagAlias

Inherits:
Object
  • Object
show all
Defined in:
lib/jpush/model/tag_alias.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ TagAlias

Returns a new instance of TagAlias.


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jpush/model/tag_alias.rb', line 4

def initialize(opts = {})
  if opts[:add] != nil
    if  opts[:add].class == Array
      @add = opts[:add]
    else
      raise ArgumentError.new('add should be array.')
    end
  end

  if opts[:remove] != nil
    if  opts[:remove].class == Array
      @remove = opts[:remove]
    else
      raise ArgumentError.new('add should be array.')
    end
  end

  if opts[:alias] != nil
    @alias = opts[:alias]
  end
end

Instance Attribute Details

#addObject

Returns the value of attribute add


3
4
5
# File 'lib/jpush/model/tag_alias.rb', line 3

def add
  @add
end

#aliasObject

Returns the value of attribute alias


3
4
5
# File 'lib/jpush/model/tag_alias.rb', line 3

def alias
  @alias
end

#removeObject

Returns the value of attribute remove


3
4
5
# File 'lib/jpush/model/tag_alias.rb', line 3

def remove
  @remove
end

#tagsObject

Returns the value of attribute tags


3
4
5
# File 'lib/jpush/model/tag_alias.rb', line 3

def tags
  @tags
end

Class Method Details

.build(opts = {}) ⇒ Object


57
58
59
60
# File 'lib/jpush/model/tag_alias.rb', line 57

def self.build(opts = {})
  tagAlias = JPush::TagAlias.new(opts)
  return tagAlias
end

.clearObject


50
51
52
53
54
55
# File 'lib/jpush/model/tag_alias.rb', line 50

def self.clear
  tags = JPush::TagAlias.new
  tags.tags = ''
  tags.alias = ''
  return tags;
end

Instance Method Details

#toJSONObject


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jpush/model/tag_alias.rb', line 26

def toJSON
  hash = {}
  tags = {}
  if @add != nil
    tags['add'] = @add
  end
  if @remove != nil
    tags['remove'] = @remove
  end
  if @alias != nil
    hash['alias'] = @alias
  end
  if @tags == ''
   hash['tags'] = @tags
   else
     hash['tags'] = tags  
  end
  
  return hash
end