# Return numeric array
def self.getarray(s)
- getlong(s).times.collect do
- getvalue(s)
- end
+ Array.new(getlong(s)) { getvalue(s) }
end
# Return object/hash
presetcategory = ""
# StringIO.open(txt) do |file|
File.open("#{Rails.root}/config/potlatch/presets.txt") do |file|
- file.each_line do|line|
+ file.each_line do |line|
t = line.chomp
if t =~ %r{(\w+)/(\w+)}
presettype = $1
kv = $2
presetnames[presettype][presetcategory].push(pre)
presets[pre] = {}
- kv.split(",").each do|a|
+ kv.split(",").each do |a|
presets[pre][$1] = $2 if a =~ /^(.+)=(.*)$/
end
end
# Read auto-complete
autotags = { "point" => {}, "way" => {}, "POI" => {} }
File.open("#{Rails.root}/config/potlatch/autocomplete.txt") do |file|
- file.each_line do|line|
+ file.each_line do |line|
next unless line.chomp =~ %r{^([\w:]+)/(\w+)\s+(.+)$}
tag = $1
type = $2
values = $3
- if values == "-"
- autotags[type][tag] = []
- else
- autotags[type][tag] = values.split(",").sort.reverse
- end
+ autotags[type][tag] = if values == "-"
+ []
+ else
+ values.split(",").sort.reverse
+ end
end
end