Sha256: 413d6806acc2ed80297f5cd4f15c885e96d37cb74334b7806cfe5f9d3861f90b
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
module QuakeliveApi module Parser class Awards < Base def earned awards = document.css(selector(:earned)) if awards awards.map { |node| parse_node(node) } end end def unearned document.css(selector(:unearned)).map { |node| parse_node(node) } end private def selectors { :earned => ".detailArea", :unearned => ".detailArea_off" } end def parse_node(node) attrs = { :icon => node.at('img')['src'], :info => node.at('img')['title'], :name => node.at('span.bigRedTxt').content, :description => node.at('span.blktxt_11').content, :awarded => awarded_at(node) } Items::Award.new(attrs) end def awarded_at(node) return unless node.css('ul.fl li').count >= 3 matches = node.at('ul.fl li:first-child').content.match(/(\d{2})\/(\d{2})\/(\d{4})/) Date.new(matches[3].to_i, matches[1].to_i, matches[2].to_i) unless matches.nil? end end class CareerMilestones < Awards; end class Experience < Awards; end class MadSkillz < Awards; end class SocialLife < Awards; end class SweetSuccess < Awards; end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quakelive_api-0.0.1 | lib/quakelive_api/parser/awards.rb |