Class: JPush::Message
- Inherits:
-
Object
- Object
- JPush::Message
- Defined in:
- lib/jpush/model/message.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#extras ⇒ Object
Returns the value of attribute extras.
-
#msg_content ⇒ Object
Returns the value of attribute msg_content.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Message
constructor
A new instance of Message.
- #toJSON ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Message
Returns a new instance of Message.
4 5 6 7 8 9 |
# File 'lib/jpush/model/message.rb', line 4 def initialize(opts = {}) @title = opts[:title] @msg_content = opts[:msg_content] @content_type = opts[:content_type] @extras = opts[:extras] end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
3 4 5 |
# File 'lib/jpush/model/message.rb', line 3 def content_type @content_type end |
#extras ⇒ Object
Returns the value of attribute extras.
3 4 5 |
# File 'lib/jpush/model/message.rb', line 3 def extras @extras end |
#msg_content ⇒ Object
Returns the value of attribute msg_content.
3 4 5 |
# File 'lib/jpush/model/message.rb', line 3 def msg_content @msg_content end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/jpush/model/message.rb', line 3 def title @title end |
Class Method Details
.build(opts = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/jpush/model/message.rb', line 28 def self.build(opts = {}) = JPush::Message.new(opts) if nil == .msg_content raise ArgumentError.new('msgContent should be set') end return end |
Instance Method Details
#toJSON ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jpush/model/message.rb', line 11 def toJSON array = {} if @title != nil then array['title'] = @title end if @msg_content != nil then array['msg_content'] = @msg_content end if @content_type != nil then array['content_type'] = @content_type end if @extras != nil then array['extras'] = @extras end return array end |