switch an unless/else and fix indentation and language

Andrew Cantino лет %!s(int64=11): %!d(string=назад)
Родитель
Сommit
3261a066ce
1 измененных файлов с 20 добавлено и 19 удалено
  1. 20 19
      app/models/agents/adioso_agent.rb

+ 20 - 19
app/models/agents/adioso_agent.rb

@@ -1,26 +1,27 @@
1 1
 module Agents
2 2
   class AdiosoAgent < Agent
3 3
 
4
-  cannot_receive_events!
4
+    cannot_receive_events!
5 5
 
6
-	default_schedule "every_1d"
6
+  	default_schedule "every_1d"
7 7
 
8
-  description <<-MD
9
-		Adioso Agent will tell you about the minimum airline prices between a pair of cities, and between a certain period of time.
10
-    Currency is USD, Please make sure difference between `start_date` and `end_date` is less than 150 days. You will need to contact [Adioso](http://adioso.com/)
11
-		for `username` and `password`.
12
-  MD
8
+    description <<-MD
9
+  		The Adioso Agent will tell you the minimum airline prices between a pair of cities, and within a certain period of time.
10
+      The currency is USD. Please make sure that the difference between `start_date` and `end_date` is less than 150 days. You will need to contact [Adioso](http://adioso.com/)
11
+  		for a `username` and `password`.
12
+    MD
13 13
 
14
-  event_description <<-MD
14
+    event_description <<-MD
15
+      If flights are present then events look like:
15 16
 
16
-    If flights are present then events look like:
17
-			{ "cost" : 75.23,
18
-        "date" : "June 25, 2013",
19
-			  "route" : "New York to Chicago" }
17
+  		    { "cost" : 75.23,
18
+            "date" : "June 25, 2013",
19
+  			    "route" : "New York to Chicago" }
20 20
 
21
-    otherwise
22
-     { "nonetodest" : "No flights found to the specified destination" }
23
-  MD
21
+      otherwise
22
+    
23
+          { "nonetodest" : "No flights found to the specified destination" }
24
+    MD
24 25
 
25 26
     def default_options
26 27
       {
@@ -53,15 +54,15 @@ module Agents
53 54
       parse_response = HTTParty.get "http://api.adioso.com/v2/search/parse?q=#{URI.encode(options[:from])}+to+#{URI.encode(options[:to])}", auth_options
54 55
       fare_request = parse_response["search_url"].gsub /(end=)(\d*)([^\d]*)(\d*)/, "\\1#{date_to_unix_epoch(options[:end_date])}\\3#{date_to_unix_epoch(options[:start_date])}"
55 56
       fare = HTTParty.get fare_request, auth_options
56
-			unless fare["warnings"]
57
+
58
+			if fare["warnings"]
59
+				create_event :payload => fare["warnings"]
60
+			else
57 61
 				event = fare["results"].min {|a,b| a["cost"] <=> b["cost"]}
58 62
 				event["date"]  = Time.at(event["date"]).to_date.httpdate[0..15]
59 63
 				event["route"] = "#{options[:from]} to #{options[:to]}" 
60 64
 				create_event :payload => event
61
-			else
62
-				create_event :payload => fare["warnings"]
63 65
 			end
64
-				
65 66
     end
66 67
   end
67 68
 end