Class: Factorio::Cache
- Inherits:
-
Object
- Object
- Factorio::Cache
- Defined in:
- lib/factorio/mod/cache.rb
Overview
Cache mod info
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
Instance Method Summary collapse
-
#any(better = :information) ⇒ Nokogiri::HTML
Get any page that already downloads.
-
#downloads ⇒ Nokogiri::HTML
Get the
Downloadspage. -
#information ⇒ Nokogiri::HTML
Get the
Informationpage. -
#initialize(uri, cookie = '') ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize(uri, cookie = '') ⇒ Cache
Returns a new instance of Cache.
9 10 11 12 13 |
# File 'lib/factorio/mod/cache.rb', line 9 def initialize(uri, = '') @uri = uri @cookie = @cache = {} end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
6 7 8 |
# File 'lib/factorio/mod/cache.rb', line 6 def cache @cache end |
Instance Method Details
#any(better = :information) ⇒ Nokogiri::HTML
Get any page that already downloads. Get better(default information) mod page if none of the pages exist.
31 32 33 34 35 36 37 38 39 |
# File 'lib/factorio/mod/cache.rb', line 31 def any(better = :information) if @cache.key? better @cache[better] elsif @cache.any? @cache.first.second else public_method(better).call end end |
#downloads ⇒ Nokogiri::HTML
Get the Downloads page.
23 24 25 |
# File 'lib/factorio/mod/cache.rb', line 23 def downloads get :downloads, "#{@uri}/downloads" end |
#information ⇒ Nokogiri::HTML
Get the Information page.
17 18 19 |
# File 'lib/factorio/mod/cache.rb', line 17 def information get :information, @uri end |