namaz 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +39 -10
  3. data/lib/namaz.rb +29 -1
  4. data/lib/namaz/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b39bf28d699c1998b865cd87b3e6d3c4ea67ba2
4
- data.tar.gz: f3a4f0a38adfbf56479dbd898bd0b5d5cbe6ceba
3
+ metadata.gz: 00a014d75a7276b009668a2f0ae8a348f3d45307
4
+ data.tar.gz: 6abb47879abeb515c7c0e50c9d374ce3af1bab39
5
5
  SHA512:
6
- metadata.gz: fdb13b1901f4cd8c936d5be1b9db383e1b3a6695ec3d568bfd03f10c4f6bfc9b271450be33417a1a89a0aa15443e8579c46b96a981540b1105f0ec33ceb0cdc6
7
- data.tar.gz: b1283a5803549a5ab9003326134f6d9035b6bedc6eceb859ce1b56a5d01184319c0fd8341a74a43fc70df9186fa19fda9cffc7a5530d55fa28c47e0834fdfbed
6
+ metadata.gz: aeef25610a99af0a7ed6c75faaa7411c04be4d0d88fba6eaafd124131db849772936dbc5c0b9b86536b4da88e0a68901e60dce70460b24ad020df6ba662612f7
7
+ data.tar.gz: dfd9a5130f48702e5b77925a00ceb52172cc949053e5e3c6ef8f704fad6c95b5be339a1e57b07ea1e8fd0d835f51ea005af605bb45e483b20ce5978268a8bfbf
data/README.md CHANGED
@@ -30,9 +30,9 @@ Make sure you require the library, where you want to use it, Or require in `appl
30
30
  ```ruby
31
31
  require 'namaz'
32
32
  ```
33
- ## Timings
34
33
 
35
- You can then make requests to the following method.
34
+ ## Timings
35
+ Returns all prayer times for a specific date and for a specific date in a city. You can then make requests to the following method.
36
36
  ```ruby
37
37
  ## Using Altitudes:
38
38
  Namaz.timings(latitude:, longitude:, timezonestring:, method:, options: {})
@@ -64,7 +64,7 @@ timings.Fajr
64
64
  ```
65
65
 
66
66
  ## Calender
67
-
67
+ Returns prayer times for a specific month (in a given year) and for a specific month in a city
68
68
  ```ruby
69
69
  ## Using City and Country Information:
70
70
  Namaz.calender_by_city(city:, country:, method:, options: {})
@@ -100,7 +100,7 @@ calendar.first.date
100
100
  ##### Example Request Using Country and City Information
101
101
 
102
102
  ```ruby
103
- calendar = Namaz.calender_by_city(city: 'Lahore', country: 'PK', method: 2, options: {month: '03', year: '2017'})
103
+ calendar = Namaz.calender_by_city(city: 'Lahore', country: 'PK', method: 2, options: {month: '02', year: '2017'})
104
104
 
105
105
  calendar.first
106
106
  #<Hashie::Mash date=#<Hashie::Mash readable="01 Feb 2017" timestamp="1485921661"> timings=#<Hashie::Mash Asr="15:54 (PKT)" Dhuhr="12:46 (PKT)" Fajr="05:56 (PKT)" Imsak="05:46 (PKT)" Isha="19:35 (PKT)" Maghrib="18:17 (PKT)" Midnight="00:46 (PKT)" Sunrise="07:14 (PKT)" Sunset="18:17 (PKT)">>
@@ -115,6 +115,37 @@ calendar.first.date
115
115
  #<Hashie::Mash readable="01 Feb 2017" timestamp="1485921661">
116
116
  ```
117
117
 
118
+ ## City Information
119
+ Returns City Geolocation Info of latitude, longitude and timezone for a given city
120
+ ### Example:
121
+ ```ruby
122
+ city_info = Namaz.city_info(city: 'Lahore', country: 'PK', options: {state: 'Punjab'})
123
+ #<Hashie::Mash latitude="31.5546061" longitude="74.3571581" timezone="Asia/Karachi">
124
+ city_info.longitude
125
+ # => "74.3571581"
126
+ city_info.timezone
127
+ # => "Asia/Karachi"
128
+ ```
129
+
130
+ ## Address Information
131
+ Returns Address Geolocation Info of latitude, longitude and timezone for a given city
132
+
133
+ ### Additional Parameter
134
+
135
+ **address** - A complete address string. Example: 10 Upper Bank Street, London, Canary Wharf, London, UK
136
+
137
+ ### Examples:
138
+ ```ruby
139
+ address_info = address_info(address: '10 Upper Bank Street, London, Canary Wharf, London, UK')
140
+ #<Hashie::Mash latitude="51.5026562" longitude="-0.0171995" timezone="Europe/London">
141
+ -- OR --
142
+ address_info = address_info(address: 'Upper Bank Street, London, Canary Wharf, London, UK')
143
+ #<Hashie::Mash latitude=51.5045201 longitude=-0.0171009 timezone="Europe/London">
144
+ -- OR --
145
+ address_info = address_info(address: 'Bank Street, London, Canary Wharf, London, UK')
146
+ #<Hashie::Mash latitude=51.5035329 longitude=-0.0213304 timezone="Europe/London">
147
+ ```
148
+
118
149
  ## General Parameters Description
119
150
  * **timestamp OPTIONAL** - `DEFAULT = Time.now.to_i` a UNIX timestamp (from any time of the day) of the day for which you want the timings. If you don't specify a timestamp, the result will come back for today - today being the date in the Europe/London timezone.
120
151
 
@@ -163,17 +194,15 @@ end
163
194
 
164
195
  ## CHANGE LOG:
165
196
 
166
- * **0.1.0:** Request Using Altitudes
167
- * **0.1.1:** Added new request Using Country and City Information
197
+ * **0.1.4:** Added methods `city_info` and `address_info`
198
+ * **0.1.3:** Added methods `calendar` and `calendar_by_city`
168
199
  * **0.1.2:** Updated method name for Timings information for city from `timings` to `timings_by_city`
200
+ * **0.1.1:** Added new request Using Country and City Information
201
+ * **0.1.0:** Request Using Altitudes
169
202
 
170
203
  ## TODO:
171
204
  Follow the link https://aladhan.com/prayer-times-api and add patch by creating a Pull Rquest, I will merge and publish new version
172
205
 
173
- * Current Time Stamp
174
- * Current Time
175
- * City Geolocation Info
176
- * Address Geolocation Info
177
206
  * Timings by Address
178
207
  * Calendar by Address
179
208
 
@@ -8,6 +8,35 @@ module Namaz
8
8
  DEFAULT_API_URL = 'http://api.aladhan.com'
9
9
 
10
10
  class << self
11
+ # Retrieve the latitude, longitude and timezone for a given city
12
+ # @param [String] city
13
+ # @param [String] country
14
+ # @param [Hash] options state is OPTIONAL
15
+ # @return [Hashie::Mash] having latitude longitude and timezone
16
+ def city_info(city:, country:, options: {})
17
+ url = [DEFAULT_API_URL, 'cityInfo'].join('/')
18
+
19
+ params = {
20
+ city: city,
21
+ country: country,
22
+ state: options[:state]
23
+ }
24
+
25
+ response = connection.get(url, params)
26
+ return Hashie::Mash.new(MultiJson.load(response.body)).data if response.success?
27
+ end
28
+
29
+ # Retrieve the latitude, longitude and timezone for given address
30
+ # @param [address] A complete address string
31
+ # @return [Hashie::Mash] having latitude longitude and timezone
32
+ def address_info(address:)
33
+ url = [DEFAULT_API_URL, 'addressInfo'].join('/')
34
+
35
+ params = { address: address }
36
+ response = connection.get(url, params)
37
+ return Hashie::Mash.new(MultiJson.load(response.body)).data if response.success?
38
+ end
39
+
11
40
  # Retrieve the namaz timings for a given latitude, longitude, timezonestring and method.
12
41
  #
13
42
  # @param [Float] latitude.
@@ -97,7 +126,6 @@ module Namaz
97
126
  namaz_calender_response(namaz_url, params)
98
127
  end
99
128
 
100
-
101
129
  # Build or get an HTTP connection object.
102
130
  def connection
103
131
  @connection ||= Faraday.new
@@ -1,3 +1,3 @@
1
1
  module Namaz
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namaz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sohair Ahmad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday