Class: AppNews

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_idObject (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

#authorObject (readonly)

Returns the value of attribute author.



14
15
16
# File 'lib/steam/community/app_news.rb', line 14

def author
  @author
end

#contentsObject (readonly)

Returns the value of attribute contents.



14
15
16
# File 'lib/steam/community/app_news.rb', line 14

def contents
  @contents
end

#dateObject (readonly)

Returns the value of attribute date.



14
15
16
# File 'lib/steam/community/app_news.rb', line 14

def date
  @date
end

#feed_labelObject (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_nameObject (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

#gidObject (readonly)

Returns the value of attribute gid.



14
15
16
# File 'lib/steam/community/app_news.rb', line 14

def gid
  @gid
end

#titleObject (readonly)

Returns the value of attribute title.



14
15
16
# File 'lib/steam/community/app_news.rb', line 14

def title
  @title
end

#urlObject (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)

Returns:

  • (Boolean)


43
44
45
# File 'lib/steam/community/app_news.rb', line 43

def external?
  @external
end