class Map::Tube::MapLoader
Attributes
city[RW]
map_path[RW]
Public Class Methods
new(city_name, map_path=nil)
click to toggle source
# File lib/map/tube/map_loader.rb, line 6 def initialize(city_name, map_path=nil) @city = city_name.split(' ').join("_") if map_path # Always trust the path if it comes from the user @map_path = map_path else @map_path = set_path_for_city end end
Public Instance Methods
read()
click to toggle source
# File lib/map/tube/map_loader.rb, line 15 def read if File.exist?(@map_path) Parser.new(File.open(@map_path)).parse! else raise Map::Tube::Exceptions::CityException, "Map for #{@city} does not exist" end end
Private Instance Methods
filename(city_name)
click to toggle source
# File lib/map/tube/map_loader.rb, line 29 def filename(city_name) "#{city_name.downcase}-map.xml" end
set_path_for_city()
click to toggle source
# File lib/map/tube/map_loader.rb, line 25 def set_path_for_city Gem.datadir("map-tube") + "/" + filename(@city) end