Class: Chronic::Span

Inherits:
Range
  • Object
show all
Defined in:
lib/chronic/chronic.rb

Overview

A Span represents a range of time. Since this class extends Range, you can use #begin and #end to get the beginning and ending times of the span (they will be of class Time)

Instance Method Summary collapse

Instance Method Details

#+(seconds) ⇒ Object

Add a number of seconds to this span, returning the resulting Span



201
202
203
# File 'lib/chronic/chronic.rb', line 201

def +(seconds)
  Span.new(self.begin + seconds, self.end + seconds)
end

#-(seconds) ⇒ Object

Subtract a number of seconds to this span, returning the resulting Span



207
208
209
# File 'lib/chronic/chronic.rb', line 207

def -(seconds)
  self + -seconds
end

#to_sObject

Prints this span in a nice fashion



212
213
214
# File 'lib/chronic/chronic.rb', line 212

def to_s
  '(' << self.begin.to_s << '..' << self.end.to_s << ')'
end

#widthObject

Returns the width of this span in seconds



195
196
197
# File 'lib/chronic/chronic.rb', line 195

def width
  (self.end - self.begin).to_i
end