class PopflashMatchDownloader::MatchFileNameExtractor
Constants
- DEMO_LINK_REGEX
- MATCH_URL_PREFIX
Public Class Methods
new(match_id)
click to toggle source
# File lib/popflash_match_downloader/match_file_name_extractor.rb, line 3 def initialize match_id @match_id = match_id end
Public Instance Methods
extract_file_name()
click to toggle source
# File lib/popflash_match_downloader/match_file_name_extractor.rb, line 10 def extract_file_name match_url = MATCH_URL_PREFIX + @match_id doc = Nokogiri::HTML open(match_url) link = doc.css('a.demo-download').first raise UnexpectedContentError if link == nil match_id_match = link['href'].match(DEMO_LINK_REGEX) raise UnexpectedContentError if match_id_match == nil match_id_match.captures.first end