Class: MinxingRubySdk::Ocu::ArticleMessage
- Defined in:
- lib/minxing_ruby_sdk/ocu/article_message.rb
Instance Attribute Summary collapse
-
#articles ⇒ Object
Returns the value of attribute articles.
Instance Method Summary collapse
- #body ⇒ Object
- #common_article_json(article) ⇒ Object
-
#initialize ⇒ ArticleMessage
constructor
A new instance of ArticleMessage.
- #resource_article_json(article) ⇒ Object
Constructor Details
#initialize ⇒ ArticleMessage
Returns a new instance of ArticleMessage.
6 7 8 |
# File 'lib/minxing_ruby_sdk/ocu/article_message.rb', line 6 def initialize @articles = [] end |
Instance Attribute Details
#articles ⇒ Object
Returns the value of attribute articles.
4 5 6 |
# File 'lib/minxing_ruby_sdk/ocu/article_message.rb', line 4 def articles @articles end |
Instance Method Details
#body ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/minxing_ruby_sdk/ocu/article_message.rb', line 10 def body size = @articles.size if size > 0 json = '{"article_count":' + size.to_s + ',"articles":[' for i in 0...size if i>0 json += ',' end json += '{' if articles[i].type == 'resource' json += resource_article_json(articles[i]) else json += common_article_json(articles[i]) end json += '}' end json +=']}' end json end |
#common_article_json(article) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/minxing_ruby_sdk/ocu/article_message.rb', line 32 def common_article_json(article) json = "" json += '"title":"' + article.title + '"' unless article.title.nil? json += ',"description":"' + article.description + '"' unless article.description.nil? json += ',"pic_url":"' + article.pic_url + '"' unless article.pic_url.nil? json += ',"url":"' + article.url + '"' unless article.url.nil? json += ',"app_url":"' + article.app_url + '"' unless article.app_url.nil? json end |
#resource_article_json(article) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/minxing_ruby_sdk/ocu/article_message.rb', line 41 def resource_article_json(article) json = "" json += '"type":"' + article.type + '"' unless article.type.nil? json += ',"resource_id":"' + article.resource_id.to_s + '"' unless article.resource_id.nil? json end |