Class: ModOrganizer::Download
- Inherits:
-
Object
- Object
- ModOrganizer::Download
- Extended by:
- Memoist
- Defined in:
- lib/mod_organizer/download.rb
Overview
Object storing information about a downloaded file and giving a lazy API on it to save resources
Instance Method Summary collapse
-
#downloaded_date ⇒ Object
Download date of the source.
-
#downloaded_file_path ⇒ Object
Full downloaded file path.
-
#initialize(mod_organizer, file_name) ⇒ Download
constructor
Constructor.
-
#nexus_file_id ⇒ Object
NexusMods file ID.
-
#nexus_file_name ⇒ Object
NexusMods file name.
-
#nexus_mod_id ⇒ Object
NexusMods mod ID.
Constructor Details
#initialize(mod_organizer, file_name) ⇒ Download
Constructor
- Parameters
-
mod_organizer (ModOrganizer): The Mod Organizer instance this mod has been instantiated for
-
file_name (String): The file name for this download
15 16 17 18 |
# File 'lib/mod_organizer/download.rb', line 15 def initialize(mod_organizer, file_name) @mod_organizer = mod_organizer @file_name = file_name end |
Instance Method Details
#downloaded_date ⇒ Object
Download date of the source
- Result
-
Time or nil: Download date of this source, or nil if no file
33 34 35 36 |
# File 'lib/mod_organizer/download.rb', line 33 def downloaded_date file_path = downloaded_file_path file_path ? File.mtime(file_path).utc : nil end |
#downloaded_file_path ⇒ Object
Full downloaded file path
- Result
-
String or nil: Full downloaded file path, or nil if does not exist
24 25 26 27 |
# File 'lib/mod_organizer/download.rb', line 24 def downloaded_file_path full_path = "#{@mod_organizer.downloads_dir}/#{@file_name}" File.exist?(full_path) ? full_path : nil end |
#nexus_file_id ⇒ Object
NexusMods file ID
- Result
- Integer
-
File ID from NexusMods
58 59 60 |
# File 'lib/mod_organizer/download.rb', line 58 def nexus_file_id ['General']['fileID'] end |
#nexus_file_name ⇒ Object
NexusMods file name
- Result
- String
-
Original file name from NexusMods
42 43 44 |
# File 'lib/mod_organizer/download.rb', line 42 def nexus_file_name ['General']['name'] end |
#nexus_mod_id ⇒ Object
NexusMods mod ID
- Result
- Integer
-
Mod ID from NexusMods
50 51 52 |
# File 'lib/mod_organizer/download.rb', line 50 def nexus_mod_id ['General']['modID'] end |