lib/www/enbujyo.rb in holysugar-www-enbujyo-0.1.6 vs lib/www/enbujyo.rb in holysugar-www-enbujyo-0.1.7
- old
+ new
@@ -104,19 +104,23 @@
def get_selection_info_build(prefix, rep)
deck = Deck.new
rep.keys.grep(/#{prefix}card_params_\d/).sort.each{|k|
deck.cards.push WWW::Enbujyo::Card.parse_from_jsonstr(rep[k])
}
- deck.gcards.push(WWW::Enbujyo::Gunshi.new(
- :image => rep[prefix+'staff_image'],
- :level => rep[prefix+'staff_level'],
- :longname => rep[prefix+'staff_name'],
- :team => rep[prefix+'staff_seiryoku_name'],
- :attribute => rep[prefix+'staff_zokusei_name'],
- :strategy => rep[prefix+'strategy_name'],
- :ex => rep[prefix+'skill_ex_name']
- ))
+ %w|0 1|.each do |num|
+ next unless rep[prefix+'staff_image_'+num]
+
+ deck.gcards.push(WWW::Enbujyo::Gunshi.new(
+ :image => rep[prefix+'staff_image_'+num],
+ :level => rep[prefix+'staff_level_'+num],
+ :longname => rep[prefix+'staff_name_'+num],
+ :team => rep[prefix+'staff_seiryoku_name_'+num],
+ :attribute => rep[prefix+'staff_zokusei_name'],
+ :strategy => rep[prefix+'strategy_name'],
+ :ex => rep[prefix+'skill_ex_name']
+ ))
+ end
player = WWW::Enbujyo::Player.new(
:name => rep[prefix+'name'],
:name_image_url => rep[prefix+'image'],
:team => rep[prefix+'team_name'],
:title => rep[prefix+'grade_name'],
@@ -147,9 +151,10 @@
/filename="(.*\.wmv)"/ =~ @agent.page.response['content-disposition']
filename = windows? ? $1 : NKF.nkf('-Sw', $1)
end
FileUtils.mv(tmpname, filename)
puts "Downloading #{filename} has finished." unless silent?
+ filename
end
private
def random_string(length = 10, strings = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
Array.new(length).map{ strings[rand(strings.size),1] }.join