Class: Integer

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

Overview

Monkey-patched Integer class enabled to return Timerizer::Durations.

Examples:

5.minutes
# => 5 minutes

See Also:

Instance Method Summary collapse

Instance Method Details

#centuries(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(centuries: self)`.

Examples:

n.centuries == Timerizer::Duration.new(centuries: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.centuries x.minutes) == (n.centuries + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



225
# File 'lib/timerizer.rb', line 225

self._define_duration_unit(:centuries)

#century(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(century: self)`.

Examples:

n.century == Timerizer::Duration.new(century: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.century x.minutes) == (n.century + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



235
# File 'lib/timerizer.rb', line 235

self._define_duration_unit(:century)

#day(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(day: self)`.

Examples:

n.day == Timerizer::Duration.new(day: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.day x.minutes) == (n.day + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



230
# File 'lib/timerizer.rb', line 230

self._define_duration_unit(:day)

#days(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(days: self)`.

Examples:

n.days == Timerizer::Duration.new(days: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.days x.minutes) == (n.days + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



220
# File 'lib/timerizer.rb', line 220

self._define_duration_unit(:days)

#decade(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(decade: self)`.

Examples:

n.decade == Timerizer::Duration.new(decade: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.decade x.minutes) == (n.decade + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



234
# File 'lib/timerizer.rb', line 234

self._define_duration_unit(:decade)

#decades(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(decades: self)`.

Examples:

n.decades == Timerizer::Duration.new(decades: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.decades x.minutes) == (n.decades + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



224
# File 'lib/timerizer.rb', line 224

self._define_duration_unit(:decades)

#hour(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(hour: self)`.

Examples:

n.hour == Timerizer::Duration.new(hour: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.hour x.minutes) == (n.hour + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



229
# File 'lib/timerizer.rb', line 229

self._define_duration_unit(:hour)

#hours(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(hours: self)`.

Examples:

n.hours == Timerizer::Duration.new(hours: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.hours x.minutes) == (n.hours + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



219
# File 'lib/timerizer.rb', line 219

self._define_duration_unit(:hours)

#millennia(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(millennia: self)`.

Examples:

n.millennia == Timerizer::Duration.new(millennia: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.millennia x.minutes) == (n.millennia + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



226
# File 'lib/timerizer.rb', line 226

self._define_duration_unit(:millennia)

#millennium(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(millennium: self)`.

Examples:

n.millennium == Timerizer::Duration.new(millennium: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.millennium x.minutes) == (n.millennium + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



236
# File 'lib/timerizer.rb', line 236

self._define_duration_unit(:millennium)

#minute(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(minute: self)`.

Examples:

n.minute == Timerizer::Duration.new(minute: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.minute x.minutes) == (n.minute + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



228
# File 'lib/timerizer.rb', line 228

self._define_duration_unit(:minute)

#minutes(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(minutes: self)`.

Examples:

n.minutes == Timerizer::Duration.new(minutes: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.minutes x.minutes) == (n.minutes + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



218
# File 'lib/timerizer.rb', line 218

self._define_duration_unit(:minutes)

#month(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(month: self)`.

Examples:

n.month == Timerizer::Duration.new(month: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.month x.minutes) == (n.month + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



232
# File 'lib/timerizer.rb', line 232

self._define_duration_unit(:month)

#months(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(months: self)`.

Examples:

n.months == Timerizer::Duration.new(months: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.months x.minutes) == (n.months + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



222
# File 'lib/timerizer.rb', line 222

self._define_duration_unit(:months)

#second(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(second: self)`.

Examples:

n.second == Timerizer::Duration.new(second: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.second x.minutes) == (n.second + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



227
# File 'lib/timerizer.rb', line 227

self._define_duration_unit(:second)

#seconds(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(seconds: self)`.

Examples:

n.seconds == Timerizer::Duration.new(seconds: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.seconds x.minutes) == (n.seconds + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



217
# File 'lib/timerizer.rb', line 217

self._define_duration_unit(:seconds)

#week(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(week: self)`.

Examples:

n.week == Timerizer::Duration.new(week: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.week x.minutes) == (n.week + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



231
# File 'lib/timerizer.rb', line 231

self._define_duration_unit(:week)

#weeks(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(weeks: self)`.

Examples:

n.weeks == Timerizer::Duration.new(weeks: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.weeks x.minutes) == (n.weeks + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



221
# File 'lib/timerizer.rb', line 221

self._define_duration_unit(:weeks)

#year(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(year: self)`.

Examples:

n.year == Timerizer::Duration.new(year: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.year x.minutes) == (n.year + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



233
# File 'lib/timerizer.rb', line 233

self._define_duration_unit(:year)

#years(other = nil) ⇒ Timerizer::Duration

Return a Timerizer::Duration with ‘self` of the given unit. This method is a helper that is equivalent to `Timerizer::Duration::new(years: self)`.

Examples:

n.years == Timerizer::Duration.new(years: n)
5.minutes == Timerizer::Duration.new(minutes: 5)
(1.week 1.day) == 8.days # "Chaining" multiple units
(n.years x.minutes) == (n.years + x.minutes)

Parameters:

  • other (Timerizer::Duration, nil) (defaults to: nil)

    Another duration to add to the resulting duration, if present. This argument allows “chaining” multiple durations together, to combine multiple units succiently.

Returns:

See Also:



223
# File 'lib/timerizer.rb', line 223

self._define_duration_unit(:years)