biz 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e58755b16da3f9c2c9de70bcc5936254292f7a0b
4
- data.tar.gz: 91739dad8b667cdd079e87b4f4cadf67b01f53cd
3
+ metadata.gz: 6fce08ec05e3857a5344b99ecd544e182ad1a877
4
+ data.tar.gz: db94653d507d2be6c3b6b2ea6ba12ea13c57afd8
5
5
  SHA512:
6
- metadata.gz: 727209e4febee006be3c79846a4e577f4c14ca2b942cf7cc1e5fcb9cb7fc8e34e4f16fad8128eb8485abd43b5e48db5cb44214d49e616c07272775ff27a3cbfe
7
- data.tar.gz: 357bc50b2a8411d2516bbf0bedb5dc3b9535fc9a81677f0d67303a8e276bfa15f9adc738f7c05ecb5f3bf1b68d41ea3640bc984f9673ba49d5ad8d89a098ca4a
6
+ metadata.gz: a55c8051f5980fc7ec592631bf597f72b66699820df7de97fab3b2dbffaab7a1db6bb81c4a59c5ec4794bf62a40b24e282c319a6a057ffab0612957c3a9d96d7
7
+ data.tar.gz: bac1486b182762a98ba869643e8271fb3cedc93a69f34579560f91b9e933125b5a5fafb085ad9002a05c027bba359259e431b4513db54bdca11cfc865ec2f384
data/README.md CHANGED
@@ -84,6 +84,9 @@ Biz.within(Time.utc(2015, 3, 7), Time.utc(2015, 3, 14)).in_seconds
84
84
 
85
85
  # Determine if a time is in business hours
86
86
  Biz.in_hours?(Time.utc(2015, 1, 10, 9))
87
+
88
+ # Determine if a time is on a holiday
89
+ Biz.on_holiday?(Time.utc(2014, 1, 1))
87
90
  ```
88
91
 
89
92
  Note that all returned times are in UTC.
@@ -135,6 +138,8 @@ require 'biz/core_ext'
135
138
 
136
139
  Time.utc(2015, 8, 20, 9, 30).business_hours?
137
140
 
141
+ Time.utc(2014, 1, 1, 12).on_holiday?
142
+
138
143
  Date.new(2015, 12, 10).business_day?
139
144
  ```
140
145
 
data/lib/biz.rb CHANGED
@@ -29,6 +29,7 @@ module Biz
29
29
  within
30
30
  in_hours?
31
31
  business_hours?
32
+ on_holiday?
32
33
  ] => :schedule
33
34
 
34
35
  private
@@ -3,6 +3,7 @@ module Biz
3
3
  end
4
4
  end
5
5
 
6
- require 'biz/calculation/for_duration'
7
- require 'biz/calculation/duration_within'
8
6
  require 'biz/calculation/active'
7
+ require 'biz/calculation/duration_within'
8
+ require 'biz/calculation/for_duration'
9
+ require 'biz/calculation/on_holiday'
@@ -0,0 +1,21 @@
1
+ module Biz
2
+ module Calculation
3
+ class OnHoliday
4
+
5
+ def initialize(schedule, time)
6
+ @schedule = schedule
7
+ @time = time
8
+ end
9
+
10
+ def result
11
+ schedule.holidays.any? { |holiday| holiday.contains?(time) }
12
+ end
13
+
14
+ protected
15
+
16
+ attr_reader :schedule,
17
+ :time
18
+
19
+ end
20
+ end
21
+ end
@@ -4,6 +4,10 @@ module Biz
4
4
  def business_hours?
5
5
  Biz.in_hours?(self)
6
6
  end
7
+
8
+ def on_holiday?
9
+ Biz.on_holiday?(self)
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -36,6 +36,10 @@ module Biz
36
36
  Calculation::Active.new(self, time).result
37
37
  end
38
38
 
39
+ def on_holiday?(time)
40
+ Calculation::OnHoliday.new(self, time).result
41
+ end
42
+
39
43
  alias_method :business_hours?, :in_hours?
40
44
 
41
45
  def in_zone
@@ -1,3 +1,3 @@
1
1
  module Biz
2
- VERSION = '1.2.2'
2
+ VERSION = '1.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Little
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-16 00:00:00.000000000 Z
12
+ date: 2015-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: abstract_type
@@ -123,6 +123,7 @@ files:
123
123
  - lib/biz/calculation/active.rb
124
124
  - lib/biz/calculation/duration_within.rb
125
125
  - lib/biz/calculation/for_duration.rb
126
+ - lib/biz/calculation/on_holiday.rb
126
127
  - lib/biz/configuration.rb
127
128
  - lib/biz/core_ext.rb
128
129
  - lib/biz/core_ext/date.rb