class BnetScraper::Starcraft2::Profile

Attributes

account[RW]
achievement_points[RW]
career_games[RW]
clan_name[RW]
clan_tag[RW]
current_solo_league[RW]
current_team_league[RW]
games_this_season[RW]
highest_solo_league[RW]
highest_team_league[RW]
leagues[RW]
portrait[RW]
protoss_swarm_level[RW]
swarm_levels[RW]
terran_campaign_completion[RW]
terran_swarm_level[RW]
url[RW]
zerg_campaign_completion[RW]
zerg_swarm_level[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 10
def initialize options = {}
  options.each_key do |key|
    self.send "#{key}=", options[key]
  end
end

Public Instance Methods

achievements() click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 16
def achievements
  @achievements ||= AchievementScraper.new(url: url).scrape
end
campaign_completion() click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 44
def campaign_completion
  {
    terran: @terran_campaign_completion,
    zerg: @zerg_campaign_completion
  }
end
completed_campaign(campaign, difficulty = :normal) click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 51
def completed_campaign campaign, difficulty = :normal
  difficulties = [:unearned, :normal, :hard, :brutal]
  ranking = campaign_completion[campaign]
  if difficulties.index(ranking) >= difficulties.index(difficulty)
    true
  else
    false
  end
end
match_history() click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 32
def match_history
  @match_history ||= MatchHistoryScraper.new(url: url).scrape
end
progress_achievements() click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 24
def progress_achievements
  achievements[:progress]
end
recent_achievements() click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 20
def recent_achievements
  achievements[:recent]
end
scrape() click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 61
def scrape
  scraper = ProfileScraper.new(url: @url)
  scraper.scrape

  scraped_data = scraper.output
  scraped_data.each_key do |key|
    self.send "#{key}=", scraped_data[key]
  end
end
showcase_achievements() click to toggle source
# File lib/bnet_scraper/starcraft2/profile.rb, line 28
def showcase_achievements
  achievements[:showcase]
end