Class: FileScheduler::TimeInterval
- Defined in:
- lib/file_scheduler/time_interval.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #include?(time) ⇒ Boolean (also: #matches?)
-
#initialize(from, to) ⇒ TimeInterval
constructor
A new instance of TimeInterval.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(from, to) ⇒ TimeInterval
Returns a new instance of TimeInterval.
8 9 10 |
# File 'lib/file_scheduler/time_interval.rb', line 8 def initialize(from, to) @from, @to = from, to end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
6 7 8 |
# File 'lib/file_scheduler/time_interval.rb', line 6 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
6 7 8 |
# File 'lib/file_scheduler/time_interval.rb', line 6 def to @to end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 25 26 |
# File 'lib/file_scheduler/time_interval.rb', line 22 def ==(other) [:from, :to].all? do |attribute| other.respond_to?(attribute) and send(attribute) == other.send(attribute) end end |
#include?(time) ⇒ Boolean Also known as: matches?
12 13 14 15 16 17 18 |
# File 'lib/file_scheduler/time_interval.rb', line 12 def include?(time) if from > to not time.between?(to, from) else time.between?(from, to) end end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/file_scheduler/time_interval.rb', line 32 def inspect to_s end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/file_scheduler/time_interval.rb', line 28 def to_s "#{from}-#{to}" end |