Class: Boundy::Domain::Finite
- Inherits:
-
Object
- Object
- Boundy::Domain::Finite
- Includes:
- Plugin
- Defined in:
- lib/boundy/domain/finite.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(b, e) ⇒ Finite
constructor
A new instance of Finite.
- #partially_after?(subject) ⇒ Boolean
- #partially_before?(subject) ⇒ Boolean
- #partially_within?(subject) ⇒ Boolean
- #strictly_after?(subject) ⇒ Boolean
- #strictly_earlier?(subject) ⇒ Boolean
- #valid? ⇒ Boolean
Methods included from Plugin
Constructor Details
#initialize(b, e) ⇒ Finite
Returns a new instance of Finite.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/boundy/domain/finite.rb', line 18 def initialize(b,e) case b when Boundy::Bound @from = b @to = e else raise "I can't convert #{b.class.name} into a Boundy::Domain::Finite" end unless valid? raise "Backlooking ranges aren't allowed.\n\nFROM: #{@from.inspect}\nTO: #{@to.inspect}" end end |
Class Method Details
Instance Method Details
#partially_after?(subject) ⇒ Boolean
49 50 51 |
# File 'lib/boundy/domain/finite.rb', line 49 def partially_after?(subject) @from.after?(subject) && @to.within?(subject) end |
#partially_before?(subject) ⇒ Boolean
53 54 55 |
# File 'lib/boundy/domain/finite.rb', line 53 def partially_before?(subject) @from.within?(subject) && @to.before?(subject) end |
#partially_within?(subject) ⇒ Boolean
57 58 59 60 61 |
# File 'lib/boundy/domain/finite.rb', line 57 def partially_within?(subject) [:within?, :partially_before?, :partially_after?].any? do |m| send(m, subject) end end |
#strictly_after?(subject) ⇒ Boolean
45 46 47 |
# File 'lib/boundy/domain/finite.rb', line 45 def strictly_after?(subject) @to.after?(subject) end |
#strictly_earlier?(subject) ⇒ Boolean
41 42 43 |
# File 'lib/boundy/domain/finite.rb', line 41 def strictly_earlier?(subject) @from.before?(subject) end |