Class: JPush::Options
- Inherits:
-
Object
- Object
- JPush::Options
- Defined in:
- lib/jpush/model/options.rb
Instance Attribute Summary collapse
-
#apns_production ⇒ Object
Returns the value of attribute apns_production.
-
#big_push_duration ⇒ Object
Returns the value of attribute big_push_duration.
-
#override_msg_id ⇒ Object
Returns the value of attribute override_msg_id.
-
#sendno ⇒ Object
Returns the value of attribute sendno.
-
#time_to_live ⇒ Object
Returns the value of attribute time_to_live.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Options
constructor
A new instance of Options.
- #toJSON ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Options
Returns a new instance of Options.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jpush/model/options.rb', line 4 def initialize(opts = {}) if opts[:apns_production] != nil @apns_production = opts[:apns_production] else @apns_production = false end @sendno = opts[:sendno] if opts[:time_to_live] != nil @time_to_live = opts[:time_to_live] else @time_to_live = 86400 end @overrride_msg_id = opts[:override_msg_id] @big_push_duration = opts[:big_push_duration] end |
Instance Attribute Details
#apns_production ⇒ Object
Returns the value of attribute apns_production.
3 4 5 |
# File 'lib/jpush/model/options.rb', line 3 def apns_production @apns_production end |
#big_push_duration ⇒ Object
Returns the value of attribute big_push_duration.
3 4 5 |
# File 'lib/jpush/model/options.rb', line 3 def big_push_duration @big_push_duration end |
#override_msg_id ⇒ Object
Returns the value of attribute override_msg_id.
3 4 5 |
# File 'lib/jpush/model/options.rb', line 3 def override_msg_id @override_msg_id end |
#sendno ⇒ Object
Returns the value of attribute sendno.
3 4 5 |
# File 'lib/jpush/model/options.rb', line 3 def sendno @sendno end |
#time_to_live ⇒ Object
Returns the value of attribute time_to_live.
3 4 5 |
# File 'lib/jpush/model/options.rb', line 3 def time_to_live @time_to_live end |
Class Method Details
.build(opts = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jpush/model/options.rb', line 42 def self.build(opts = {}) = JPush::Options.new(opts) if .sendno != nil && .sendno < 0 raise ArgumentError.new('sendno should be greater than 0.') end if .override_msg_id != nil && .override_msg_id < 0 raise ArgumentError.new(' override_msg_id should be greater than 0.') end if .time_to_live != nil && .time_to_live < 0 raise ArgumentError.new('time_to_live should be greater than 0.') end if .big_push_duration != nil && .big_push_duration > 1440 raise ArgumentError.new('big_push_duration should be less than 1440.') end if .big_push_duration != nil && .big_push_duration <= 0 raise ArgumentError.new('big_push_duration should be greater than 0.') end return end |
Instance Method Details
#toJSON ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jpush/model/options.rb', line 22 def toJSON array = {} if @sendno != nil then array['sendno'] = @sendno end if @time_to_live != nil then array['time_to_live'] = @time_to_live end if @override_msg_id != nil then array['override_msg_id'] = @override_msg_id end if @apns_production != nil then array['apns_production'] = @apns_production end if @big_push_duration != nil then array['big_push_duration'] = @big_push_duration end return array end |