class TspRunner::LocationHash

Attributes

locations[R]

Public Class Methods

from_file(filename) click to toggle source
# File lib/tsp_runner/location_hash.rb, line 5
def self.from_file(filename)
  new.tap do |location_hash|
    File.open(filename).each do |line|
      name, lat_str, lon_str = *line.chomp.split(',')
      location_hash << Location.new(name, Float(lat_str), Float(lon_str))
    end
  end
end
new() click to toggle source
# File lib/tsp_runner/location_hash.rb, line 14
def initialize
  @locations = {}
end

Public Instance Methods

<<(location) click to toggle source
# File lib/tsp_runner/location_hash.rb, line 18
def <<(location)
  locations[location.name] = location
end
[](location_name) click to toggle source
# File lib/tsp_runner/location_hash.rb, line 22
def [](location_name)
  locations[location_name]
end
location_names() click to toggle source
# File lib/tsp_runner/location_hash.rb, line 26
def location_names
  locations.keys
end