Class: ModOrganizer::Download

Inherits:
Object
  • Object
show all
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

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_dateObject

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_pathObject

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_idObject

NexusMods file ID

Result
  • Integer

    File ID from NexusMods



58
59
60
# File 'lib/mod_organizer/download.rb', line 58

def nexus_file_id
  meta_ini['General']['fileID']
end

#nexus_file_nameObject

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
  meta_ini['General']['name']
end

#nexus_mod_idObject

NexusMods mod ID

Result
  • Integer

    Mod ID from NexusMods



50
51
52
# File 'lib/mod_organizer/download.rb', line 50

def nexus_mod_id
  meta_ini['General']['modID']
end