Class: JPush::Platform

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Platform

Returns a new instance of Platform.


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

def initialize(opts = {})
  if opts[:android] != nil
    @android = opts[:android]
  else
    @android = false
  end
  if opts[:ios] != nil
    @ios = opts[:ios]
  else
    @ios = false
  end
  if opts[:winphone] != nil
    @winphone = opts[:winphone]
  else
    @winphone = false
  end
end

Instance Attribute Details

#androidObject

Returns the value of attribute android


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

def android
  @android
end

#iosObject

Returns the value of attribute ios


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

def ios
  @ios
end

#winphoneObject

Returns the value of attribute winphone


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

def winphone
  @winphone
end

Class Method Details

.allObject


40
41
42
43
44
45
46
# File 'lib/jpush/model/platform.rb', line 40

def self.all
  pl = JPush::Platform.new
  pl.ios = true
  pl.android = true
  pl.winphone = true
  return pl
end

.build(opts = {}) ⇒ Object


48
49
50
51
52
53
54
# File 'lib/jpush/model/platform.rb', line 48

def self.build(opts = {})
  platform = JPush::Platform.new(opts)
  if platform.android != true&&platform.ios != true&&platform.winphone != true
    raise ArgumentError.new('No any deviceType is set.')
  end
  return platform
end

Instance Method Details

#toJSONObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/jpush/model/platform.rb', line 22

def toJSON
  if @android == true && @ios ==true && @winphone == true
    return 'all'
  else
    array = Array.new
    if @android == true then
      array.push('android')
    end
    if @ios == true then
      array.push('ios')
    end
    if @winphone == true then
      array.push('winphone')
    end
  end
  return array
end