Class: AppNews
- Inherits:
-
Object
- Object
- AppNews
- Defined in:
- lib/steam/community/app_news.rb
Overview
This class represents Steam news and can be used to load a list of current news about specific games
Instance Attribute Summary collapse
-
#app_id ⇒ Fixnum
readonly
Returns the Steam Application ID of the game this news belongs to.
-
#author ⇒ String
readonly
Returns the name of the author of this news.
-
#contents ⇒ String
readonly
Returns the contents of this news.
-
#date ⇒ Time
readonly
Returns the date this news item has been published.
-
#feed_label ⇒ String
readonly
Returns the name of the feed this news item belongs to.
-
#feed_name ⇒ String
readonly
Returns the symbolic name of the feed this news item belongs to.
-
#gid ⇒ Fixnum
readonly
Returns a unique identifier for this news.
-
#title ⇒ String
readonly
Returns the title of this news.
-
#url ⇒ String
readonly
Returns the URL of the original news.
Class Method Summary collapse
-
.news_for_app(app_id, count = 5, max_length = nil) ⇒ Array<AppNews>
Loads the news for the given game with the given restrictions.
Instance Method Summary collapse
-
#external? ⇒ Boolean
Returns whether this news item originates from a source other than Steam itself (e.g. an external blog).
-
#to_s ⇒ String
Returns a simple textual representation of this news item.
Instance Attribute Details
#app_id ⇒ Fixnum (readonly)
Returns the Steam Application ID of the game this news belongs to
19 20 21 |
# File 'lib/steam/community/app_news.rb', line 19 def app_id @app_id end |
#author ⇒ String (readonly)
Returns the name of the author of this news
24 25 26 |
# File 'lib/steam/community/app_news.rb', line 24 def @author end |
#contents ⇒ String (readonly)
Depending on the setting for the maximum length of a news (see news_for_app), the contents might be truncated.
Returns the contents of this news
This might contain HTML code.
33 34 35 |
# File 'lib/steam/community/app_news.rb', line 33 def contents @contents end |
#date ⇒ Time (readonly)
Returns the date this news item has been published
38 39 40 |
# File 'lib/steam/community/app_news.rb', line 38 def date @date end |
#feed_label ⇒ String (readonly)
Returns the name of the feed this news item belongs to
43 44 45 |
# File 'lib/steam/community/app_news.rb', line 43 def feed_label @feed_label end |
#feed_name ⇒ String (readonly)
Returns the symbolic name of the feed this news item belongs to
48 49 50 |
# File 'lib/steam/community/app_news.rb', line 48 def feed_name @feed_name end |
#gid ⇒ Fixnum (readonly)
Returns a unique identifier for this news
53 54 55 |
# File 'lib/steam/community/app_news.rb', line 53 def gid @gid end |
#title ⇒ String (readonly)
Returns the title of this news
58 59 60 |
# File 'lib/steam/community/app_news.rb', line 58 def title @title end |
#url ⇒ String (readonly)
Returns the URL of the original news
This is a direct link to the news on the Steam website or a redirecting link to the external post.
66 67 68 |
# File 'lib/steam/community/app_news.rb', line 66 def url @url end |
Class Method Details
.news_for_app(app_id, count = 5, max_length = nil) ⇒ Array<AppNews>
Loads the news for the given game with the given restrictions
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/steam/community/app_news.rb', line 81 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', 2, params) news_items = [] MultiJson.load(data, { :symbolize_keys => true })[:appnews][:newsitems].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 item originates from a source other than Steam itself (e.g. an external blog)
97 98 99 |
# File 'lib/steam/community/app_news.rb', line 97 def external? @external end |
#to_s ⇒ String
Returns a simple textual representation of this news item
Will consist of the name of the feed this news belongs to and the title of the news.
107 108 109 |
# File 'lib/steam/community/app_news.rb', line 107 def to_s "#@feed_label: #@title" end |