class Arkrb::Mod
Attributes
id[RW]
Public Class Methods
new(mod_id)
click to toggle source
# File lib/arkrb/server/mod.rb, line 6 def initialize(mod_id) @id = mod_id.to_i @workshop_url = "https://steamcommunity.com/sharedfiles/filedetails/?id=#{mod_id}" @changelog_url = "https://steamcommunity.com/sharedfiles/filedetails/changelog/#{mod_id}" does_mod_exist? @name = update_mod_name @version_tag = latest_version_tag end
Public Instance Methods
does_mod_exist?()
click to toggle source
# File lib/arkrb/server/mod.rb, line 35 def does_mod_exist? document = Oga.parse_html(open(workshop_url)) if document.at_css('div[class="error_ctn"] h3').text == 'That item does not exist. It may have been removed by the author.' raise Arkrb::Error::ModDoesNotExist, "Woah the mod #{id} does not exist!" end rescue NoMethodError true end
latest_version_tag()
click to toggle source
# File lib/arkrb/server/mod.rb, line 29 def latest_version_tag document = Oga.parse_html(open(changelog_url)) version = document.at_css('div[class~="workshopAnnouncement"]:nth-child(3) > div[class="headline"]').text.strip Digest::MD5.hexdigest(version).strip end
to_h()
click to toggle source
# File lib/arkrb/server/mod.rb, line 44 def to_h { id: id, name: name, version_tag: version_tag, workshop_url: workshop_url, changelog_url: changelog_url } end
Also aliased as: to_hash
update_info()
click to toggle source
# File lib/arkrb/server/mod.rb, line 19 def update_info self.name = update_mod_name self.version = latest_version_tag end
update_mod_name()
click to toggle source
# File lib/arkrb/server/mod.rb, line 24 def update_mod_name document = Oga.parse_html(open(changelog_url)) document.at_css('div[class="workshopItemTitle"]').text end