Class: Factorio::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/factorio/mod/cache.rb

Overview

cache mod info

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, cookie = '') ⇒ Cache

Returns a new instance of Cache.



6
7
8
9
10
11
# File 'lib/factorio/mod/cache.rb', line 6

def initialize(uri, cookie = '')
  @uri = uri
  @cookie = cookie
  @gotten = {}
  @gotten.default = false
end

Instance Attribute Details

#gottenObject (readonly)

Returns the value of attribute gotten.



4
5
6
# File 'lib/factorio/mod/cache.rb', line 4

def gotten
  @gotten
end

Instance Method Details

#anyObject



21
22
23
24
25
26
27
28
29
# File 'lib/factorio/mod/cache.rb', line 21

def any
  if gotten[:mod]
    mod
  elsif gotten[:download]
    download
  else
    send i[mod download][rand(2)]
  end
end

#downloadObject



17
18
19
# File 'lib/factorio/mod/cache.rb', line 17

def download
  get :download, "#{@uri}/downloads"
end

#modObject



13
14
15
# File 'lib/factorio/mod/cache.rb', line 13

def mod
  get :mod, @uri
end