artic 1.0.0 → 1.0.1

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: 677bcdd6f44140488725e808cc21352cae9a637d
4
- data.tar.gz: f8c0969a9fe9a90483bbe8daede9739b6f59f0c2
3
+ metadata.gz: f6d3493f33b4a7bda30633981f19e2dc57d127b4
4
+ data.tar.gz: ac48612706ed362f442ba3d10677cf80e2201b41
5
5
  SHA512:
6
- metadata.gz: 4892f61298533796efdb513c5f34a1a15cea5c999a9485c8da110df61482170acbbe7cbb1f33ecb84402671279a2060b8d052337f8b349a8cfa1c47edaa32f35
7
- data.tar.gz: 7c4199ff8a5478a62eb36a94e02a5c0a2e15c0e929c402cb0d81df5da44abffe682b3e1f3e9988b6ec22515284f0cb837c037a44fbd864ca4ec40a1d20dc715e
6
+ metadata.gz: f67b26be6c5d8b28d60a1a89553da7ae6144b6e0bd3e998b47fc0243cd0b2941967dc69e086d4829b57e72b84dcc0fdc4699b92a61b8ec580a04a47511231d44
7
+ data.tar.gz: b08d848f3a69a34ae826fe05247ee34030c1f1a10c9d5bdb180363b82f4f5d59f69d04c7d5d2169cb9e172cee48a56a69b79d9caded652bea7a11e81c4df3e30
@@ -14,18 +14,18 @@ module Artic
14
14
  #
15
15
  # @return [TimeRange] the passed time range or a new time range
16
16
  def build(range)
17
- range.is_a?(TimeRange) ? range : TimeRange.new(range.min, range.max)
17
+ range.is_a?(TimeRange) ? range : TimeRange.new(range.begin, range.end)
18
18
  end
19
19
  end
20
20
 
21
21
  # Initializes a new range.
22
22
  #
23
- # @param min [String] the start time (in HH:MM format)
24
- # @param max [String] the end time (in HH:MM format)
23
+ # @param start_time [String] the start time (in HH:MM format)
24
+ # @param end_time [String] the end time (in HH:MM format)
25
25
  #
26
26
  # @raise [ArgumentError] if the start time or the end time is invalid
27
27
  # @raise [ArgumentError] if the start time is after the end time
28
- def initialize(min, max)
28
+ def initialize(start_time, end_time)
29
29
  super
30
30
  validate_range
31
31
  end
@@ -37,7 +37,7 @@ module Artic
37
37
  #
38
38
  # @return [Boolean]
39
39
  def overlaps?(other)
40
- min <= other.max && max >= other.min
40
+ self.begin <= other.end && self.end >= other.begin
41
41
  end
42
42
 
43
43
  # Returns whether this range completely covers the one given.
@@ -46,7 +46,7 @@ module Artic
46
46
  #
47
47
  # @return [Boolean]
48
48
  def covers?(other)
49
- min <= other.min && max >= other.max
49
+ self.begin <= other.begin && self.end >= other.end
50
50
  end
51
51
 
52
52
  # Returns a range of +DateTime+ objects for this time range.
@@ -56,8 +56,8 @@ module Artic
56
56
  # @return [Range]
57
57
  def with_date(date)
58
58
  Range.new(
59
- DateTime.parse("#{date} #{min}"),
60
- DateTime.parse("#{date} #{max}")
59
+ DateTime.parse("#{date} #{self.begin}"),
60
+ DateTime.parse("#{date} #{self.end}")
61
61
  )
62
62
  end
63
63
 
@@ -98,15 +98,15 @@ module Artic
98
98
  return [other] unless overlaps?(other)
99
99
  return [] if covers?(other)
100
100
 
101
- if min <= other.min && max <= other.max
102
- [max..other.max]
103
- elsif min >= other.min && max <= other.max
101
+ if self.begin <= other.begin && self.end <= other.end
102
+ [self.end..other.end]
103
+ elsif self.begin >= other.begin && self.end <= other.end
104
104
  [
105
- (other.min..min),
106
- (max..other.max)
105
+ (other.begin..self.begin),
106
+ (self.end..other.end)
107
107
  ]
108
- elsif min >= other.min && max >= other.max
109
- [other.min..min]
108
+ elsif self.begin >= other.begin && self.end >= other.end
109
+ [other.begin..self.begin]
110
110
  end
111
111
  end
112
112
 
@@ -115,18 +115,18 @@ module Artic
115
115
  def validate_range
116
116
  fail(
117
117
  ArgumentError,
118
- "#{min} is not a valid time"
119
- ) unless min =~ TIME_REGEX
118
+ "#{self.begin} is not a valid time"
119
+ ) unless self.begin =~ TIME_REGEX
120
120
 
121
121
  fail(
122
122
  ArgumentError,
123
- "#{max} is not a valid time"
124
- ) unless max =~ TIME_REGEX
123
+ "#{self.end} is not a valid time"
124
+ ) unless self.end =~ TIME_REGEX
125
125
 
126
126
  fail(
127
127
  ArgumentError,
128
- "#{min} is greater than #{max}"
129
- ) if min > max
128
+ "#{self.begin} is greater than #{self.end}"
129
+ ) if self.begin > self.end
130
130
  end
131
131
  end
132
132
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Artic
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Desantis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-02 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo