Class: FactorioMods::Mod

Inherits:
Object
  • Object
show all
Defined in:
lib/factorio_mods/mod.rb

Defined Under Namespace

Classes: MediaFile, Release, Tag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Mod

Returns a new instance of Mod.



91
92
93
94
95
# File 'lib/factorio_mods/mod.rb', line 91

def initialize(data = {})
  data.each do |k, v|
    send "#{k}=".to_sym, v if respond_to? "#{k}=".to_sym
  end
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



88
89
90
# File 'lib/factorio_mods/mod.rb', line 88

def created_at
  @created_at
end

#current_user_ratingObject

Returns the value of attribute current_user_rating.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def current_user_rating
  @current_user_rating
end

#descriptionObject

Returns the value of attribute description.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def description
  @description
end

#description_htmlObject

Returns the value of attribute description_html.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def description_html
  @description_html
end

#downloads_countObject

Returns the value of attribute downloads_count.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def downloads_count
  @downloads_count
end

#game_versionsObject

Returns the value of attribute game_versions.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def game_versions
  @game_versions
end

#github_pathObject

Returns the value of attribute github_path.



88
89
90
# File 'lib/factorio_mods/mod.rb', line 88

def github_path
  @github_path
end

#homepageObject

Returns the value of attribute homepage.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def homepage
  @homepage
end

#idObject

Returns the value of attribute id.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def id
  @id
end

#license_flagsObject

Returns the value of attribute license_flags.



88
89
90
# File 'lib/factorio_mods/mod.rb', line 88

def license_flags
  @license_flags
end

#license_flags_rawObject (readonly)

Returns the value of attribute license_flags_raw.



88
89
90
# File 'lib/factorio_mods/mod.rb', line 88

def license_flags_raw
  @license_flags_raw
end

#license_nameObject

Returns the value of attribute license_name.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def license_name
  @license_name
end

#license_urlObject

Returns the value of attribute license_url.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def license_url
  @license_url
end

#media_filesObject

Returns the value of attribute media_files.



88
89
90
# File 'lib/factorio_mods/mod.rb', line 88

def media_files
  @media_files
end

#nameObject

Returns the value of attribute name.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def name
  @name
end

#ownerObject

Returns the value of attribute owner.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def owner
  @owner
end

#ratings_countObject

Returns the value of attribute ratings_count.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def ratings_count
  @ratings_count
end

#releasesObject

Returns the value of attribute releases.



88
89
90
# File 'lib/factorio_mods/mod.rb', line 88

def releases
  @releases
end

#summaryObject

Returns the value of attribute summary.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def summary
  @summary
end

#tagsObject

Returns the value of attribute tags.



88
89
90
# File 'lib/factorio_mods/mod.rb', line 88

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def title
  @title
end

#updated_atObject

Returns the value of attribute updated_at.



88
89
90
# File 'lib/factorio_mods/mod.rb', line 88

def updated_at
  @updated_at
end

#visits_countObject

Returns the value of attribute visits_count.



84
85
86
# File 'lib/factorio_mods/mod.rb', line 84

def visits_count
  @visits_count
end

Instance Method Details

#first_media_fileObject



109
110
111
112
# File 'lib/factorio_mods/mod.rb', line 109

def first_media_file
  return media_files.first if media_files
  @first_media_file
end

#first_media_file=(file) ⇒ Object



114
115
116
# File 'lib/factorio_mods/mod.rb', line 114

def first_media_file=(file)
  @first_media_file = MediaFile.new file
end

#latest_releaseObject



118
119
120
121
# File 'lib/factorio_mods/mod.rb', line 118

def latest_release
  return releases.max { |r| r.released_at.to_i } if releases
  @latest_release
end

#latest_release=(release) ⇒ Object



123
124
125
# File 'lib/factorio_mods/mod.rb', line 123

def latest_release=(release)
  @latest_release = Release.new release
end

#reload!Object



97
98
99
100
101
102
103
# File 'lib/factorio_mods/mod.rb', line 97

def reload!
  data = FactorioMods::Api::ModPortal.raw_mod(name)
  data.each do |k, v|
    send "#{k}=".to_sym, v if respond_to? "#{k}=".to_sym
  end
  true
end