Class: Nauvisian::API
- Inherits:
-
Object
- Object
- Nauvisian::API
- Defined in:
- lib/nauvisian/api.rb
Overview
Mod Portal API wiki.factorio.com/Mod_portal_API
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #detail(mod) ⇒ Object
-
#initialize ⇒ API
constructor
A new instance of API.
- #releases(mod) ⇒ Object
Constructor Details
#initialize ⇒ API
Returns a new instance of API.
19 20 21 |
# File 'lib/nauvisian/api.rb', line 19 def initialize @cache = Nauvisian::Cache::FileSystem.new(name: "api") end |
Instance Method Details
#detail(mod) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/nauvisian/api.rb', line 23 def detail(mod) with_error_handling(mod) do path = "/api/mods/#{mod.name}/full" raw_data = get(path) data = raw_data.slice(:downloads_count, :name, :owner, :summary, :title, :category, :description) Nauvisian::Mod::Detail[created_at: Time.parse(raw_data[:created_at]), **data] end end |
#releases(mod) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/nauvisian/api.rb', line 32 def releases(mod) with_error_handling(mod) do path = "/api/mods/#{mod.name}" raw_data = get(path) parse_releases(raw_data[:releases], mod:) end end |