Class: Itch::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
SimpleInspect
Defined in:
lib/itch/client.rb

Overview

The primary client interface

The top level client delegates to child modules for specific app areas like game and purchases pages

Instance Method Summary collapse

Methods included from SimpleInspect

#exclude_inspection, #inspect, #pretty_print_instance_variables

Constructor Details

#initialize(username: nil, password: nil, cookie_path: nil) ⇒ Client

Returns a new instance of Client.



24
25
26
27
28
29
# File 'lib/itch/client.rb', line 24

def initialize(username: nil, password: nil, cookie_path: nil)
  @agent = Mechanize.new
  @auth = Auth.new(@agent, username: username, password: password, cookie_path: cookie_path)

  @agent.cookie_jar.load(cookie_path) if cookie_path && File.readable?(cookie_path)
end

Instance Method Details

#bundlesObject



39
40
41
# File 'lib/itch/client.rb', line 39

def bundles
  @bundles ||= Bundles.new(@agent)
end

#game(id = nil, name: nil) ⇒ Object



31
32
33
# File 'lib/itch/client.rb', line 31

def game(id = nil, name: nil)
  Game.new(@agent, game_map, id, name: name)
end

#game_mapObject



43
44
45
# File 'lib/itch/client.rb', line 43

def game_map
  @game_map ||= GameMap.new(@agent)
end

#purchasesObject



35
36
37
# File 'lib/itch/client.rb', line 35

def purchases
  @purchases ||= Purchases.new(@agent)
end