Class: ModOrganizer::Source
- Inherits:
-
Object
- Object
- ModOrganizer::Source
- Defined in:
- lib/mod_organizer/source.rb
Overview
Object storing information about the source of a mod and giving a lazy API on it to save resources A mod source is something (a file from NexusMods, a manual download…) that has provided content for the mod.
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
String or nil: File name for this source, or nil if none.
-
#nexus_file_id ⇒ Object
readonly
Integer or nil: NexusMods file ID, or nil if none.
-
#nexus_mod_id ⇒ Object
readonly
Integer or nil: NexusMods mod ID, or nil if none.
Instance Method Summary collapse
-
#download ⇒ Object
Get the download info corresponding to this source, or nil if none.
-
#initialize(mod_organizer, nexus_mod_id:, nexus_file_id:, file_name:) ⇒ Source
constructor
Constructor.
-
#type ⇒ Object
The type of source.
Constructor Details
#initialize(mod_organizer, nexus_mod_id:, nexus_file_id:, file_name:) ⇒ Source
Constructor
- Parameters
-
mod_organizer (ModOrganizer): The Mod Organizer instance this mod has been instantiated for
-
nexus_mod_id (Integer): Corresponding Nexus mod id, or 0 or nil if none
-
nexus_file_id (Integer): Corresponding Nexus mod file id, or 0 or nil if none
-
file_name (String): File name that provided content to this mod, or nil if none
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mod_organizer/source.rb', line 23 def initialize( mod_organizer, nexus_mod_id:, nexus_file_id:, file_name: ) @mod_organizer = mod_organizer @nexus_mod_id = nexus_mod_id.nil? || nexus_mod_id.zero? ? nil : nexus_mod_id @nexus_file_id = nexus_file_id.nil? || nexus_file_id.zero? ? nil : nexus_file_id @file_name = file_name end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
String or nil: File name for this source, or nil if none
14 15 16 |
# File 'lib/mod_organizer/source.rb', line 14 def file_name @file_name end |
#nexus_file_id ⇒ Object (readonly)
Integer or nil: NexusMods file ID, or nil if none
11 12 13 |
# File 'lib/mod_organizer/source.rb', line 11 def nexus_file_id @nexus_file_id end |
#nexus_mod_id ⇒ Object (readonly)
Integer or nil: NexusMods mod ID, or nil if none
8 9 10 |
# File 'lib/mod_organizer/source.rb', line 8 def nexus_mod_id @nexus_mod_id end |
Instance Method Details
#download ⇒ Object
Get the download info corresponding to this source, or nil if none.
- Result
-
Download or nil: Download info, or nil if none
49 50 51 |
# File 'lib/mod_organizer/source.rb', line 49 def download @file_name ? @mod_organizer.download(file_name: @file_name) : nil end |
#type ⇒ Object
The type of source
- Result
-
Symbol: The source’s type. Can be:
-
nexus_mods: Content downloaded from NexusMods
-
unknown: Unknown source
-
41 42 43 |
# File 'lib/mod_organizer/source.rb', line 41 def type @nexus_mod_id ? :nexus_mods : :unknown end |