Class: AppNews
- Inherits:
-
Object
- Object
- AppNews
- Defined in:
- lib/steam/community/app_news.rb
Overview
The AppNews class is a representation of Steam news and can be used to load current news about specific games
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#feed_label ⇒ Object
readonly
Returns the value of attribute feed_label.
-
#feed_name ⇒ Object
readonly
Returns the value of attribute feed_name.
-
#gid ⇒ Object
readonly
Returns the value of attribute gid.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.news_for_app(app_id, count = 5, max_length = nil) ⇒ Object
Loads the news for the given game with the given restrictions.
Instance Method Summary collapse
-
#external? ⇒ Boolean
Returns whether this news items originates from a source other than Steam itself (e.g. an external blog).
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def app_id @app_id end |
#author ⇒ Object (readonly)
Returns the value of attribute author.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def @author end |
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def contents @contents end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def date @date end |
#feed_label ⇒ Object (readonly)
Returns the value of attribute feed_label.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def feed_label @feed_label end |
#feed_name ⇒ Object (readonly)
Returns the value of attribute feed_name.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def feed_name @feed_name end |
#gid ⇒ Object (readonly)
Returns the value of attribute gid.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def gid @gid end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
14 15 16 |
# File 'lib/steam/community/app_news.rb', line 14 def url @url end |
Class Method Details
.news_for_app(app_id, count = 5, max_length = nil) ⇒ Object
Loads the news for the given game with the given restrictions
app_id
-
The unique Steam Application ID of the game (e.g.
440
for Team Fortress 2). See developer.valvesoftware.com/wiki/Steam_Application_IDs for all application IDs count
-
The maximum number of news to load (default: 5). There’s no reliable way to load all news. Use really a really great number instead
max_length
-
The maximum content length of the news (default: nil). If a maximum length is defined, the content of the news will only be at most
max_length
characters long plus an ellipsis
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/steam/community/app_news.rb', line 29 def self.news_for_app(app_id, count = 5, max_length = nil) params = { :appid => app_id, :count => count, :maxlength => max_length } data = WebApi.json('ISteamNews', 'GetNewsForApp', 1, params) news_items = [] JSON.parse(data, { :symbolize_names => true })[:appnews][:newsitems][:newsitem].each do |news_data| news_items << AppNews.new(app_id, news_data) end news_items end |
Instance Method Details
#external? ⇒ Boolean
Returns whether this news items originates from a source other than Steam itself (e.g. an external blog)
43 44 45 |
# File 'lib/steam/community/app_news.rb', line 43 def external? @external end |