interval_set 0.2.0 → 0.2.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: 51dd820f1753f2caac54b95fe4cdc9b231edc550
4
- data.tar.gz: dc1416a3d1efbd7fc04c5c6fe648990de4aa3c9c
3
+ metadata.gz: 9a613b54e3bb21ed54db8f0a61a6649d872a9be5
4
+ data.tar.gz: e0b2f5995b8a3de7b12bae21e24ed0012ef313bb
5
5
  SHA512:
6
- metadata.gz: 5ffb51edc36a0a400b8e547f77e1741f41975533ecd74560f0e04946a839aa0073e28c33246a9ff66a59ca4bc00a63da1796b6c8bd320778df57afa49568912e
7
- data.tar.gz: f38d3f138965f2117e570765e0759ff43582db792a43ff0151aeb7f3a58618b53991cc511e2763dcd3a3cdd80246c420231e017d561d3056303a31b4398511eb
6
+ metadata.gz: 84359b40ffc3b226a319b729375826dffa0029ec92034bbba21754e681575769c0d58a67f31f0f25243dbe8aeaac7a1f38be41a042341ed96425ba5891c82fc6
7
+ data.tar.gz: 9ffb727f9161abcfa62c47e2ef913d18edc0f1da2ba107628701467e91b5a0f43eb59d3c53af33eaa857612b1ae818721c1d5f8356644e1f5cd546f5aa001115
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- interval_set (0.2.0)
4
+ interval_set (0.2.1)
5
5
  treemap-fork (~> 1.0, >= 1.0.4.2)
6
6
 
7
7
  GEM
@@ -36,4 +36,4 @@ DEPENDENCIES
36
36
  rspec (~> 3.7)
37
37
 
38
38
  BUNDLED WITH
39
- 1.16.0
39
+ 1.16.1
@@ -1,3 +1,3 @@
1
1
  class IntervalSet
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
data/lib/interval_set.rb CHANGED
@@ -129,6 +129,32 @@ class IntervalSet
129
129
 
130
130
  alias_method :===, :include?
131
131
 
132
+ # Returns +true+ if the closure of this IntervalSet contains the given element.
133
+ #
134
+ # The closure of a set +S+ is defined as the set containing all elements of +S+
135
+ # but also its limit points.
136
+ #
137
+ # It will always return +true+ if #include? returns +true+ but in addition it
138
+ # will also return +true+ if the exclusive end of a range is included.
139
+ #
140
+ # i = IntervalSet[0...1] # -> [0...1]
141
+ #
142
+ # i.include_or_limit?(0) # -> true
143
+ # i.include_or_limit?(0.5) # -> true
144
+ # i.include_or_limit?(1) # -> true
145
+ #
146
+ # Note that the given element must be comparable to elements already in this
147
+ # set. Otherwise, the behavior is undefined.
148
+ #
149
+ # @param element [Object]
150
+ def include_or_limit?(element)
151
+ return false if element.nil?
152
+
153
+ floor_entry = @range_map.floor_entry(element)
154
+
155
+ !floor_entry.nil? && floor_entry.value.last >= element
156
+ end
157
+
132
158
  # Returns +true+ if this IntervalSet includes all elements
133
159
  # of the other object.
134
160
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interval_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rico Jasper