lib/quakelive_api/parser/statistics.rb in quakelive_api-0.0.1 vs lib/quakelive_api/parser/statistics.rb in quakelive_api-0.1.0
- old
+ new
@@ -3,18 +3,18 @@
class Statistics < Base
def weapons
document.css(selector(:weapon)).each_with_index.map do |node, idx|
attrs = {
- :name => node.text,
- :frags => frags(weapon_next(:frags, idx)),
- :accuracy => accuracy(weapon_next(:accuracy, idx)),
- :usage => usage(weapon_next(:usage, idx))
+ name: node.text,
+ frags: frags(weapon_next(:frags, idx)),
+ accuracy: accuracy(weapon_next(:accuracy, idx)),
+ usage: usage(weapon_next(:usage, idx))
}
hits, shots = hits_shots(weapon_next(:accuracy, idx))
- attrs.merge!(:hits => hits, :shots => shots)
+ attrs.merge!(hits: hits, shots: shots)
Items::Weapon.new(attrs)
end
end
@@ -24,30 +24,30 @@
document.css(selector(:record)).map do |node|
next if no_records?
attrs = {
- :title => node.at('.col_st_gametype').text.strip,
- :played => to_integer(node.at('.col_st_played').text),
- :finished => to_integer(node.at('.col_st_finished').text),
- :wins => to_integer(node.at('.col_st_wins').text),
- :quits => to_integer(node.at('.col_st_withdraws').text),
- :completed => to_integer(node.at('.col_st_completeperc').text.gsub('%','')),
- :wins_percentage => to_integer(node.at('.col_st_winperc').text.gsub('%',''))
+ title: node.at('.col_st_gametype').text.strip,
+ played: to_integer(node.at('.col_st_played').text),
+ finished: to_integer(node.at('.col_st_finished').text),
+ wins: to_integer(node.at('.col_st_wins').text),
+ quits: to_integer(node.at('.col_st_withdraws').text),
+ completed: to_integer(node.at('.col_st_completeperc').text.gsub('%','')),
+ wins_percentage: to_integer(node.at('.col_st_winperc').text.gsub('%',''))
}
Items::Record.new(attrs)
end
end
private
def selectors
{
- :weapon => ".prf_weapons .col_weapon",
- :frags => ".col_frags",
- :accuracy => ".col_accuracy",
- :usage => ".col_usage",
- :record => ".qlv_profile_section_statistics .prf_record > div"
+ weapon: ".prf_weapons .col_weapon",
+ frags: ".col_frags",
+ accuracy: ".col_accuracy",
+ usage: ".col_usage",
+ record: ".qlv_profile_section_statistics .prf_record > div"
}
end
def no_records?
document.at(selector(:record)).nil?