KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there anyway to find the next item in a Ruby Array? Code: # Find ALL languages if !debug lang = Language.all else lang = Language.where("id = ? OR id = ?", 22, 32) end # Get all elements elements = Element.where("human_readable IS NOT NULL") lang.each do |l| code = l.code.downcase if File.exists?(file_path + code + ".yml") File.delete(file_path + code + ".yml") end t1 = Time.now info = {} elements.each do |el| unless l.id == 1 et = el.element_translations.where("language_id = ? AND complete = ?", l.id, true) else et = el.element_translations.where("language_id = ?", 1) end et.each do |tran| info[code] ||= {} info[code][el.human_readable] = tran.content.gsub("\n", "").force_encoding("UTF-8").encode! end end File.open(file_path + code + ".yml", "w", :encoding => "UTF-8") do |f| if f.write(info.to_yaml) t2 = Time.now puts code + ".yml File written" puts "It took " + time_diff_milli(t1, t2).to_s + " seconds to complete" # This is where I want to display the next item in the lang array puts lang.shift(1).inspect puts "*"*50 end end end
Tags (comma-separated)
Save Edits
Cancel