Class: SteamMist::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/steam_mist/schema.rb

Overview

TODO:

More tests.

Handles the Schema for games.

Instance Method Summary collapse

Constructor Details

#initialize(key, app_id, lang = nil) ⇒ Schema

Initialize the schema. The first argument is the application id, which valve uses internally to distinguish games from each other.

Parameters:

  • app_id (Numeric)
  • lang (String) (defaults to: nil)

    the language the schema should return its results in.



17
18
19
20
21
22
23
24
25
# File 'lib/steam_mist/schema.rb', line 17

def initialize(key, app_id, lang = nil)
  @app_id = app_id
  @session = Session.new
  @get_schema = @session.get_interface("IEconItems_#{app_id}").get_schema

  if lang
    @get_schema.with_arguments!(:language => lang)
  end
end

Instance Method Details

#dataHashie::Mash

Retrieves the data from the request.

Returns:

  • (Hashie::Mash)


37
38
39
# File 'lib/steam_mist/schema.rb', line 37

def data
  @_data ||= Hashie::Mash.new(@get_schema.get.data["result"])
end

#itemsSortedSet<Item>

Returns a list of items in the schema.

Returns:

  • (SortedSet<Item>)


30
31
32
# File 'lib/steam_mist/schema.rb', line 30

def items
  @_items ||= data.items
end