file = File.open(“food.txt”, “r”).read

out_array = []

# Parse
prev_food_line = nil
line_number = 0
file.each_line do |line|
puts ” “
# TODO parse description from parathensis? FOOD NAME(BLAH BLAH) 5?
if (line =~ /^(.*) (\d+\.?\d?)\??$/) then
out = { :food => $1, :price => $2, :type => ‘food’ }
if ($3 != nil) then
out[:description] = $3
end
prev_food_line = line_number
out_array << out

elsif (line =~ /^\s$/) then
# WHITE SPACE, NEW LINE, RETURN CARRIAGE
out_array << { :type => ‘newline’ }

elsif (prev_food_line != nil && prev_food_line + 1 == line_number) then
line.chomp!
# if prev_food_line just got processed and this is not a food line, then this line is probably a description for last known food
out_array[-1][:description] = line

else
# probably title or subtitle
line.chomp!
out_array << { :type => ‘title’, :title => line }
end

line_number += 1
end

# Output
out_array.each do |line|
case line[:type]
when ‘food’ then
puts “

}’ price=’#{line[:price]}’ description=’#{line[:description]}’]”
when ‘title’ then
puts “
}’]”
when ‘subtitle’ then
puts “
}’ description=’#{line[:description]}’]”
when ‘newline’ then
puts “

end
end

DETAILS

Lunch:
Tues – Sun, Noon-3pm
Dinner:
Mon – Thurs, 5pm-9:30pm
Fri-Sat, 5pm-10pm
Sun, 5pm-9:30pm
Location:
4255 Main St.
Philadelphia, PA 19127
(267) 297-8151
(267) 297 8341

Yanako Now Accepts Reservations Online:

Reserve Now
Eat fresh. Eat colorfully. Eat creatively.