Class: SteamMist::Session

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

Overview

The session is used as a starting point for connecting to the Steam API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connector = Connectors::LazyConnector) ⇒ Session

Initialize.

Parameters:

  • connector (Class) (defaults to: Connectors::LazyConnector)

    the connector (should be subclass of Connector).



31
32
33
34
35
# File 'lib/steam_mist/session.rb', line 31

def initialize(connector = Connectors::LazyConnector)
  @connector   = connector
  @_interfaces = {}
  @default_arguments = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Some #method_missing magic. Sorry @charliesome!

See Also:

  • SteamMist::Session.{{#get_interface}


49
50
51
52
# File 'lib/steam_mist/session.rb', line 49

def method_missing(method, *args)
  super if args.length > 0 or block_given?
  get_interface method
end

Instance Attribute Details

#connectorClass

The connector that the session is going to use.

Returns:

  • (Class)

    the connector.



21
22
23
# File 'lib/steam_mist/session.rb', line 21

def connector
  @connector
end

#default_argumentsHash

The default arguments that the session will use.

Returns:

  • (Hash)


26
27
28
# File 'lib/steam_mist/session.rb', line 26

def default_arguments
  @default_arguments
end

Instance Method Details

#get_interface(interface) ⇒ PseudoInterface

Grabs an interface for use. These are cached, so every call with the same argument returns the same object.

Parameters:

  • interface (Symbol)

    the interface name.

Returns:



42
43
44
# File 'lib/steam_mist/session.rb', line 42

def get_interface(interface)
  @_interfaces[interface] ||= PseudoInterface.new(self, interface)
end

#inspectObject

pretty inspection



55
56
57
# File 'lib/steam_mist/session.rb', line 55

def inspect
  "#<SteamMist::Session #{connector.inspect}>"
end