Class: BnetScraper::Starcraft2::Profile
- Inherits:
-
Object
- Object
- BnetScraper::Starcraft2::Profile
- Defined in:
- lib/bnet_scraper/starcraft2/profile.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#achievement_points ⇒ Object
Returns the value of attribute achievement_points.
-
#career_games ⇒ Object
Returns the value of attribute career_games.
-
#clan_name ⇒ Object
Returns the value of attribute clan_name.
-
#clan_tag ⇒ Object
Returns the value of attribute clan_tag.
-
#current_solo_league ⇒ Object
Returns the value of attribute current_solo_league.
-
#current_team_league ⇒ Object
Returns the value of attribute current_team_league.
-
#games_this_season ⇒ Object
Returns the value of attribute games_this_season.
-
#highest_solo_league ⇒ Object
Returns the value of attribute highest_solo_league.
-
#highest_team_league ⇒ Object
Returns the value of attribute highest_team_league.
-
#leagues ⇒ Object
Returns the value of attribute leagues.
-
#portrait ⇒ Object
Returns the value of attribute portrait.
-
#protoss_swarm_level ⇒ Object
Returns the value of attribute protoss_swarm_level.
-
#swarm_levels ⇒ Object
Returns the value of attribute swarm_levels.
-
#terran_campaign_completion ⇒ Object
Returns the value of attribute terran_campaign_completion.
-
#terran_swarm_level ⇒ Object
Returns the value of attribute terran_swarm_level.
-
#url ⇒ Object
Returns the value of attribute url.
-
#zerg_campaign_completion ⇒ Object
Returns the value of attribute zerg_campaign_completion.
-
#zerg_swarm_level ⇒ Object
Returns the value of attribute zerg_swarm_level.
Instance Method Summary collapse
- #achievements ⇒ Object
- #campaign_completion ⇒ Object
- #completed_campaign(campaign, difficulty = :normal) ⇒ Object
-
#initialize(options = {}) ⇒ Profile
constructor
A new instance of Profile.
- #match_history ⇒ Object
- #progress_achievements ⇒ Object
- #recent_achievements ⇒ Object
- #scrape ⇒ Object
- #showcase_achievements ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Profile
Returns a new instance of Profile.
10 11 12 13 14 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 10 def initialize = {} .each_key do |key| self.send "#{key}=", [key] end end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def account @account end |
#achievement_points ⇒ Object
Returns the value of attribute achievement_points.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def achievement_points @achievement_points end |
#career_games ⇒ Object
Returns the value of attribute career_games.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def career_games @career_games end |
#clan_name ⇒ Object
Returns the value of attribute clan_name.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def clan_name @clan_name end |
#clan_tag ⇒ Object
Returns the value of attribute clan_tag.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def clan_tag @clan_tag end |
#current_solo_league ⇒ Object
Returns the value of attribute current_solo_league.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def current_solo_league @current_solo_league end |
#current_team_league ⇒ Object
Returns the value of attribute current_team_league.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def current_team_league @current_team_league end |
#games_this_season ⇒ Object
Returns the value of attribute games_this_season.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def games_this_season @games_this_season end |
#highest_solo_league ⇒ Object
Returns the value of attribute highest_solo_league.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def highest_solo_league @highest_solo_league end |
#highest_team_league ⇒ Object
Returns the value of attribute highest_team_league.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def highest_team_league @highest_team_league end |
#leagues ⇒ Object
Returns the value of attribute leagues.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def leagues @leagues end |
#portrait ⇒ Object
Returns the value of attribute portrait.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def portrait @portrait end |
#protoss_swarm_level ⇒ Object
Returns the value of attribute protoss_swarm_level.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def protoss_swarm_level @protoss_swarm_level end |
#swarm_levels ⇒ Object
Returns the value of attribute swarm_levels.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def swarm_levels @swarm_levels end |
#terran_campaign_completion ⇒ Object
Returns the value of attribute terran_campaign_completion.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def terran_campaign_completion @terran_campaign_completion end |
#terran_swarm_level ⇒ Object
Returns the value of attribute terran_swarm_level.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def terran_swarm_level @terran_swarm_level end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def url @url end |
#zerg_campaign_completion ⇒ Object
Returns the value of attribute zerg_campaign_completion.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def zerg_campaign_completion @zerg_campaign_completion end |
#zerg_swarm_level ⇒ Object
Returns the value of attribute zerg_swarm_level.
4 5 6 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 4 def zerg_swarm_level @zerg_swarm_level end |
Instance Method Details
#achievements ⇒ Object
16 17 18 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 16 def achievements @achievements ||= AchievementScraper.new(url: url).scrape end |
#campaign_completion ⇒ Object
44 45 46 47 48 49 |
# 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) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# 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 ⇒ Object
32 33 34 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 32 def match_history @match_history ||= MatchHistoryScraper.new(url: url).scrape end |
#progress_achievements ⇒ Object
24 25 26 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 24 def progress_achievements achievements[:progress] end |
#recent_achievements ⇒ Object
20 21 22 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 20 def recent_achievements achievements[:recent] end |
#scrape ⇒ Object
61 62 63 64 65 66 67 68 69 |
# 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 ⇒ Object
28 29 30 |
# File 'lib/bnet_scraper/starcraft2/profile.rb', line 28 def showcase_achievements achievements[:showcase] end |