opening_hours_converter 1.3.8 → 1.3.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0522647daec6e61185f989eaafa5d941598197a3
4
- data.tar.gz: 553d55c9362adf5c5ca5b599f96c09b29046ad1c
3
+ metadata.gz: 33f59f13fa2cdc370c95156630a9789e52ebb3a2
4
+ data.tar.gz: ea7af1b0b5e99e622fb179b6e4c0da4dd6059436
5
5
  SHA512:
6
- metadata.gz: facfbcdd2e95cb34d3cd502688b77daddd063893e50258af80af586f4c104f371cf7e3f9c492b42fe142a2828bb917d1deb34505a531a47973d8225ffdc20a63
7
- data.tar.gz: 94dd7f5933622f28dad516d43880f693f698b15591bd52e3876ef2e94b66c376bb55e24c142d19722b24f5ffaba3ddba82d62ea4b56c4d35446f97e877467385
6
+ metadata.gz: 40af9709076c5302ff46b25226ff8ff6173129263522cf031d9f79c59a4643fe13e7d84f3cf943d591f04bd4bc56a4756bd50051306ed636302f77d387227c57
7
+ data.tar.gz: a44404b688eeeb156b0e7f228b855efc7d27a1088b16181d2e4973c03c4ce83880a59cd88ccaa283273cd27655c8cd1d391ef1ac1c7ea43239fd704c8519d476
@@ -1,5 +1,5 @@
1
1
  require 'opening_hours_converter/constants'
2
-
2
+ require 'pry-nav'
3
3
  module OpeningHoursConverter
4
4
  class OpeningHoursBuilder
5
5
  include Constants
@@ -99,7 +99,8 @@ module OpeningHoursConverter
99
99
  year_start = year
100
100
  month_start = month
101
101
  day_start = day
102
- elsif day_bool && year_start >= 0 && month == 11 && day == 30 && years[year+1].nil?
102
+ end
103
+ if day_bool && year_start >= 0 && month == 11 && day == 30 && years[year+1].nil?
103
104
  if year_start == year
104
105
  result[year] ||= []
105
106
  result[year] << { start: { day: day_start, month: month_start }, end: { day: 30, month: 11 } }
@@ -142,6 +143,7 @@ module OpeningHoursConverter
142
143
  end
143
144
  end
144
145
  end
146
+
145
147
  result_to_string(result)
146
148
  end
147
149
 
@@ -188,7 +190,11 @@ module OpeningHoursConverter
188
190
  elsif starts_month?(interval) && ends_month?(interval)
189
191
  str_result += "#{str_result.length > 5 ? "," : ""}#{OSM_MONTHS[interval[:start][:month]]}-#{OSM_MONTHS[interval[:end][:month]]}"
190
192
  elsif is_same_month?(interval)
191
- str_result += "#{str_result.length > 5 ? "," : ""}#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day]+1 < 10 ? "0#{interval[:start][:day]+1}" : interval[:start][:day]+1}-#{interval[:end][:day]+1 < 10 ? "0#{interval[:end][:day]+1}" : interval[:end][:day]+1}"
193
+ if is_same_day?(interval)
194
+ str_result += "#{str_result.length > 5 ? "," : ""}#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day]+1 < 10 ? "0#{interval[:start][:day]+1}" : interval[:start][:day]+1}"
195
+ else
196
+ str_result += "#{str_result.length > 5 ? "," : ""}#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day]+1 < 10 ? "0#{interval[:start][:day]+1}" : interval[:start][:day]+1}-#{interval[:end][:day]+1 < 10 ? "0#{interval[:end][:day]+1}" : interval[:end][:day]+1}"
197
+ end
192
198
  else
193
199
  str_result += "#{str_result.length > 5 ? "," : ""}#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day]+1 < 10 ? "0#{interval[:start][:day]+1}" : interval[:start][:day]+1}-#{OSM_MONTHS[interval[:end][:month]]} #{interval[:end][:day]+1 < 10 ? "0#{interval[:end][:day]+1}" : interval[:end][:day]+1}"
194
200
  end
@@ -215,6 +221,10 @@ module OpeningHoursConverter
215
221
  r[:start][:month] == r[:end][:month]
216
222
  end
217
223
 
224
+ def is_same_day?(r)
225
+ r[:start][:day] == r[:end][:day]
226
+ end
227
+
218
228
  def starts_month?(r)
219
229
  r[:start][:day] == 0
220
230
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opening_hours_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziserman Martin