Class: Factorix::API::MODInfo
- Inherits:
-
Data
- Object
- Data
- Factorix::API::MODInfo
- Defined in:
- lib/factorix/api/mod_info.rb,
lib/factorix/api/mod_info.rb
Overview
Defined Under Namespace
Classes: Detail
Instance Attribute Summary collapse
-
#category ⇒ Category
readonly
MOD category.
-
#detail ⇒ Detail?
readonly
Detailed information (Full API only).
-
#downloads_count ⇒ Integer
readonly
Total number of downloads.
-
#latest_release ⇒ Release?
readonly
Latest release (list API without namelist).
-
#name ⇒ String
readonly
Internal MOD name (unique identifier).
-
#owner ⇒ String
readonly
MOD owner username.
-
#releases ⇒ Array<Release>
readonly
All releases.
-
#score ⇒ Float
readonly
MOD score/rating.
-
#summary ⇒ String
readonly
Short description.
-
#thumbnail ⇒ URI::HTTPS?
readonly
Thumbnail image URL.
-
#title ⇒ String
readonly
Human-readable MOD title.
Instance Method Summary collapse
-
#initialize(name:, title:, owner:, downloads_count:, summary: nil, category: nil, score: nil, thumbnail: nil, latest_release: nil, releases: nil, **detail_fields) ⇒ MODInfo
constructor
Create MODInfo from API response hash.
Constructor Details
#initialize(name:, title:, owner:, downloads_count:, summary: nil, category: nil, score: nil, thumbnail: nil, latest_release: nil, releases: nil, **detail_fields) ⇒ MODInfo
Create MODInfo from API response hash
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/factorix/api/mod_info.rb', line 136 def initialize(name:, title:, owner:, downloads_count:, summary: nil, category: nil, score: nil, thumbnail: nil, latest_release: nil, releases: nil, **detail_fields) summary ||= "" category = Category.for(category || "") score ||= 0.0 thumbnail = thumbnail ? build_thumbnail_uri(thumbnail) : nil latest_release = latest_release ? Release[**latest_release] : nil releases = (releases || []).filter_map {|r| # NOTE: begin is required because {...} blocks cannot use rescue directly begin Release[**r] rescue RangeError => e # Skip releases with invalid version numbers Container[:logger].warn("Skipping release #{name}@#{r[:version]}: #{e.}") nil end } # Filter detail_fields to only include keys that Detail.new accepts # Exclude deprecated fields like github_path detail = Detail[**detail_fields.slice(*DETAIL_ALLOWED_KEYS)] if all_required_detail_fields?(detail_fields) super(name:, title:, owner:, summary:, downloads_count:, category:, score:, thumbnail:, latest_release:, releases:, detail:) end |
Instance Attribute Details
#category ⇒ Category (readonly)
Returns MOD category.
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def category @category end |
#detail ⇒ Detail? (readonly)
Returns detailed information (Full API only).
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def detail @detail end |
#downloads_count ⇒ Integer (readonly)
Returns total number of downloads.
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def downloads_count @downloads_count end |
#latest_release ⇒ Release? (readonly)
Returns latest release (list API without namelist).
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def latest_release @latest_release end |
#name ⇒ String (readonly)
Returns internal MOD name (unique identifier).
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def name @name end |
#owner ⇒ String (readonly)
Returns MOD owner username.
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def owner @owner end |
#releases ⇒ Array<Release> (readonly)
Returns all releases.
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def releases @releases end |
#score ⇒ Float (readonly)
Returns MOD score/rating.
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def score @score end |
#summary ⇒ String (readonly)
Returns short description.
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def summary @summary end |
#thumbnail ⇒ URI::HTTPS? (readonly)
Returns thumbnail image URL.
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def thumbnail @thumbnail end |
#title ⇒ String (readonly)
Returns human-readable MOD title.
42 43 44 |
# File 'lib/factorix/api/mod_info.rb', line 42 def title @title end |