From DojoWiki
class Weather
def getValue(filename)
day = nil
smallest = 1000
IO.foreach(filename) { | line |
if( line.length == 91 && !(line.include?('Dy')))
max = line[6..8].to_i
min = line[12..14].to_i
if ((max - min).abs < smallest)
smallest = (max - min).abs
day = line[2..4]
end
end
}
puts day
end
end
w = Weather.new
w.getValue("K4Weather.txt")
class Soccer
def getValue(filename)
team = nil
smallest = 1000
IO.foreach(filename) { | line |
if( line.length == 60 && !(line.include?('--')))
f = line[43..45].to_i
a = line[50..52].to_i
if ((f - a).abs < smallest)
smallest = (f - a).abs
team = line[7..14]
end
end
}
puts team
end
end
s = Soccer.new
s.getValue("K4Soccer.txt")