Sha256: bf9592423669fe6b52c21a0f3831bee451b43511066498968f1e2a6fac220ea4
Contents?: true
Size: 592 Bytes
Versions: 2
Compression:
Stored size: 592 Bytes
Contents
module TspRunner class LocationHash attr_reader :locations 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 def initialize @locations = {} end def <<(location) locations[location.name] = location end def [](location_name) locations[location_name] end def location_names locations.keys end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tsp_runner-0.1.1 | lib/tsp_runner/location_hash.rb |
tsp_runner-0.1.0 | lib/tsp_runner/location_hash.rb |