Permalink
Browse files

cosmetic (iterators)

  • Loading branch information...
khustochka committed Jan 29, 2010
1 parent df726b7 commit 3258a747897496f8f48316899b899a8f99aacce6
Showing with 5 additions and 7 deletions.
  1. +4 −6 lib/legacy/legacy_task.rb
  2. +1 −1 test/fixie/cities_districts_streets.rb
View
@@ -62,8 +62,7 @@ def import
:synonims => Utils.enconv(order[:ordo_syn]),
:sort => order[:ordo_id]
)
- fam_num = 0
- order.families.each do |family|
+ order.families.each_with_index do |family, fam_num|
puts " - Saving family #{family[:fam_la]}"
familia = ordo.familiae.create!(
:name_la => family[:fam_la],
@@ -72,10 +71,9 @@ def import
:name_uk => Utils.enconv(family[:fam_uk]),
:description => Utils.enconv(family[:fam_descr]),
:synonims => Utils.enconv(family[:fam_syn]),
- :sort => fam_num += 1
+ :sort => fam_num + 1
)
- sp_num = 0
- family.species.each do |sp|
+ family.species.each_with_index do |sp, sp_num|
puts " - Saving species #{sp[:sp_la]}"
species = familia.species.create!(
:code => sp[:sp_id],
@@ -87,7 +85,7 @@ def import
:description => Utils.enconv(sp[:sp_descr]),
:my_description => Utils.enconv(sp[:my_descr]),
:synonims => Utils.enconv(sp[:sp_syn]),
- :sort => sp_num += 1
+ :sort => sp_num + 1
)
end
@@ -4,7 +4,7 @@
Fixie.create(:city, :with_5_districts)
-(1..5).each do |n|
+1.upto(5) do |n|
Fixie.create(:district, "district#{n}".to_sym, :city => Fixie.cities(:with_5_districts))
end

0 comments on commit 3258a74

Please sign in to comment.