Class: Distance
- Inherits:
-
Object
- Object
- Distance
- Includes:
- DecomposerHelper
- Defined in:
- lib/turkish_cities/distance.rb
Constant Summary collapse
- CITY_LIST =
YAML.load_file(file_path)
- RADIUS_OF_EARTH =
Earth radius in km is 6371
6371
Instance Method Summary collapse
- #distance_between ⇒ Object
-
#initialize(from, to, travel_method) ⇒ Distance
constructor
A new instance of Distance.
Methods included from DecomposerHelper
#check_input_range, #cities_not_found_error, #city_not_found_error, #city_population_not_found_error, #convert_chars, #create_district_list, #create_file_path, #district_not_found_error, #find_by_between, #postcode_not_found_error, #prepare_city_list, #sort_alphabetically, #sort_input_numbers, #subdistrict_not_found_error
Constructor Details
#initialize(from, to, travel_method) ⇒ Distance
Returns a new instance of Distance.
15 16 17 18 19 |
# File 'lib/turkish_cities/distance.rb', line 15 def initialize(from, to, travel_method) @from = from @to = to @travel_method = travel_method end |
Instance Method Details
#distance_between ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/turkish_cities/distance.rb', line 21 def distance_between case @travel_method when 'land' distance_between_land when 'sea' distance_between_sea when 'air' distance_between_air else unsupported_travel_method(@travel_method) end end |