Skip to content
This repository
Browse code

Добавил "Телепорт такси", обновил цену "Арго такси".

  • Loading branch information...
commit 6f44900e9b70c49065a85109e0a01875ca247670 1 parent cfa7d68
Daniel Vartanov authored

Showing 1 changed file with 23 additions and 16 deletions. Show diff stats Hide diff stats

  1. +23 16 lib/prices.rb
39 lib/prices.rb
... ... @@ -1,35 +1,41 @@
1 1 # -*- coding: utf-8 -*-
2   -def alpha_price(distance)
  2 +
  3 +def альфа(distance)
3 4 distance < 3 ?
4 5 70 :
5 6 70 + (distance - 3) * 10
6 7 end
7 8
8   -def udacha_price(distance)
  9 +def удача(distance)
9 10 distance < 2 ?
10 11 80 :
11   - 80 + (distance - 2) * 10
  12 + 80 +
  13 + (distance - 2) * 10
12 14 end
13 15
14   -def supertaxi_price(distance)
  16 +def super_taxi(distance)
15 17 distance < 1 ?
16 18 60 :
17 19 60 + (distance - 1) * 10
18 20 end
19 21
20   -def namba_price(distance)
  22 +def намба(distance)
21 23 distance < 1 ?
22 24 50 :
23 25 50 + (distance - 1) * 10
24 26 end
25 27
26   -def argo_price(distance)
  28 +def арго(distance)
27 29 distance < 2 ?
28   - 70 :
29   - 70 + (distance - 1) * 10
  30 + 60 :
  31 + 60 + (distance - 2) * 10
30 32 end
31 33
32   -def express_price(origin, destination)
  34 +def телепорт(distance)
  35 + 45 + distance * 10
  36 +end
  37 +
  38 +def express(origin, destination)
33 39 zones = Zone.all
34 40
35 41 origin_zone = zones.find { |zone|
@@ -39,17 +45,18 @@ def express_price(origin, destination)
39 45 destination_zone = zones.find { |zone|
40 46 zone.to_polygon.contains?(destination)
41 47 }
42   -
  48 +
43 49 Price.between(origin_zone.name, destination_zone.name).value if origin_zone.present? and destination_zone.present?
44 50 end
45 51
46 52 def prices(distance, origin, destination)
47 53 {
48   - 'Express Taxi' => { :price => express_price(origin, destination), :tel => '156', :display_tel => '156' },
49   - 'Альфа такси' => { :price => alpha_price(distance), :tel => '0312579999', :display_tel => '579999' },
50   - 'Удача' => { :price => udacha_price(distance), :tel => '154', :display_tel => '154' },
51   - 'Супер такси' => { :price => supertaxi_price(distance), :tel => '152', :display_tel => '152' },
52   - 'Намба такси' => { :price => namba_price(distance), :tel => '0312976000', :display_tel => '976000' },
53   - 'Арго' => { :price => argo_price(distance), :tel => '178', :display_tel => '178' }
  54 + 'Express Taxi' => { :price => express(origin, destination), :tel => '156', :display_tel => '156' },
  55 + 'Альфа такси' => { :price => альфа(distance), :tel => '0312579999', :display_tel => '579999' },
  56 + 'Удача' => { :price => удача(distance), :tel => '154', :display_tel => '154' },
  57 + 'Супер такси' => { :price => super_taxi(distance), :tel => '152', :display_tel => '152' },
  58 + 'Намба такси' => { :price => намба(distance), :tel => '0312976000', :display_tel => '976000' },
  59 + 'Арго' => { :price => арго(distance), :tel => '178', :display_tel => '178' },
  60 + 'Телепорт' => { :price => телепорт(distance), :tel => '1336', :display_tel => '1336' }
54 61 }
55 62 end

0 comments on commit 6f44900

Please sign in to comment.
Something went wrong with that request. Please try again.