Class: PsnTrophies::Client

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

Instance Method Summary collapse

Instance Method Details

#trophies(profile_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/psn_trophies.rb', line 11

def trophies(profile_id)
  check_profile_id(profile_id)
  body = get_body("http://us.playstation.com/playstation/psn/profile/#{profile_id}/get_ordered_trophies_data",
                  "http://us.playstation.com/publictrophy/index.htm?onlinename=#{profile_id}/trophies")

  games = []
  doc = Nokogiri::HTML.fragment(body)
  doc.css('.slotcontent').each do |container|
     = container.at_css('.titlelogo img')["src"]
    title = container.at_css('.gameTitleSortField').content
    progress = container.at_css('.gameProgressSortField').content
    trophies = container.at_css('.gameTrophyCountSortField').content.strip

    games << PlayedGame.new(:image_url => , :title => title, :progress => progress, :trophy_count => trophies)
  end
  games
end