Module: TimeConstantMethods

Included in:
Numeric
Defined in:
lib/rdoc/generator/darkfish.rb

Overview

Time constants

Instance Method Summary collapse

Instance Method Details

#after(time) ⇒ Object

Returns the Time <receiver> number of seconds after the given time. E.g., 10.minutes.after( header.expiration )



436
437
438
# File 'lib/rdoc/generator/darkfish.rb', line 436

def after( time )
	return time + self
end

#agoObject

Returns the Time <receiver> number of seconds ago. (e.g., expiration > 2.hours.ago )



429
430
431
# File 'lib/rdoc/generator/darkfish.rb', line 429

def ago
	return self.before( ::Time.now )
end

#before(time) ⇒ Object

Returns the Time <receiver> number of seconds before the specified time. E.g., 2.hours.before( header.expiration )



422
423
424
# File 'lib/rdoc/generator/darkfish.rb', line 422

def before( time )
	return time - self
end

#daysObject Also known as: day

Returns the number of seconds in <receiver> days



390
391
392
# File 'lib/rdoc/generator/darkfish.rb', line 390

def days
	return self * 24.hours
end

#fortnightsObject Also known as: fortnight

Returns the number of seconds in <receiver> fortnights



402
403
404
# File 'lib/rdoc/generator/darkfish.rb', line 402

def fortnights
	return self * 2.weeks
end

#from_nowObject

Reads best without arguments: 10.minutes.from_now



441
442
443
# File 'lib/rdoc/generator/darkfish.rb', line 441

def from_now
	return self.after( ::Time.now )
end

#hoursObject Also known as: hour

Returns the number of seconds in <receiver> hours



384
385
386
# File 'lib/rdoc/generator/darkfish.rb', line 384

def hours
	return self * 60.minutes
end

#minutesObject Also known as: minute

Returns number of seconds in <receiver> minutes



378
379
380
# File 'lib/rdoc/generator/darkfish.rb', line 378

def minutes
	return self * 60
end

#monthsObject Also known as: month

Returns the number of seconds in <receiver> months (approximate)



408
409
410
# File 'lib/rdoc/generator/darkfish.rb', line 408

def months
	return self * 30.days
end

#secondsObject Also known as: second

Number of seconds (returns receiver unmodified)



372
373
374
# File 'lib/rdoc/generator/darkfish.rb', line 372

def seconds
	return self
end

#weeksObject Also known as: week

Return the number of seconds in <receiver> weeks



396
397
398
# File 'lib/rdoc/generator/darkfish.rb', line 396

def weeks
	return self * 7.days
end

#yearsObject Also known as: year

Returns the number of seconds in <receiver> years (approximate)



414
415
416
# File 'lib/rdoc/generator/darkfish.rb', line 414

def years
	return (self * 365.25.days).to_i
end