Class: Snails::Duration

Inherits:
Object show all
Defined in:
runtime/snails/duration.rbs,
runtime/snails/duration.rb

Constant Summary collapse

SECONDS_PER_MINUTE =
60
SECONDS_PER_HOUR =
3600
SECONDS_PER_DAY =
86400
SECONDS_PER_WEEK =
604800
SECONDS_PER_MONTH =
2629746
SECONDS_PER_YEAR =
31556952

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seconds) ⇒ Duration

Returns a new instance of Duration.

Parameters:



5
# File 'runtime/snails/duration.rbs', line 5

def initialize: (Integer seconds) -> void

Class Method Details

.day(n) ⇒ Duration

Parameters:

Returns:



13
# File 'runtime/snails/duration.rbs', line 13

def self.day: (Integer n) -> Duration

.days(n) ⇒ Duration

Parameters:

Returns:



12
# File 'runtime/snails/duration.rbs', line 12

def self.days: (Integer n) -> Duration

.fortnight(n) ⇒ Duration

Parameters:

Returns:



17
# File 'runtime/snails/duration.rbs', line 17

def self.fortnight: (Integer n) -> Duration

.fortnights(n) ⇒ Duration

Parameters:

Returns:



16
# File 'runtime/snails/duration.rbs', line 16

def self.fortnights: (Integer n) -> Duration

.hour(n) ⇒ Duration

Parameters:

Returns:



11
# File 'runtime/snails/duration.rbs', line 11

def self.hour: (Integer n) -> Duration

.hours(n) ⇒ Duration

Parameters:

Returns:



10
# File 'runtime/snails/duration.rbs', line 10

def self.hours: (Integer n) -> Duration

.minute(n) ⇒ Duration

Parameters:

Returns:



9
# File 'runtime/snails/duration.rbs', line 9

def self.minute: (Integer n) -> Duration

.minutes(n) ⇒ Duration

Parameters:

Returns:



8
# File 'runtime/snails/duration.rbs', line 8

def self.minutes: (Integer n) -> Duration

.month(n) ⇒ Duration

Parameters:

Returns:



19
# File 'runtime/snails/duration.rbs', line 19

def self.month: (Integer n) -> Duration

.months(n) ⇒ Duration

Parameters:

Returns:



18
# File 'runtime/snails/duration.rbs', line 18

def self.months: (Integer n) -> Duration

.second(n) ⇒ Duration

Parameters:

Returns:



7
# File 'runtime/snails/duration.rbs', line 7

def self.second: (Integer n) -> Duration

.seconds(n) ⇒ Duration

a span of n units. The singular and plural spellings build the same value; months and years use the average constants above.

Parameters:

Returns:



22
# File 'runtime/snails/duration.rb', line 22

def self.seconds: (Integer n) -> Duration

.week(n) ⇒ Duration

Parameters:

Returns:



15
# File 'runtime/snails/duration.rbs', line 15

def self.week: (Integer n) -> Duration

.weeks(n) ⇒ Duration

Parameters:

Returns:



14
# File 'runtime/snails/duration.rbs', line 14

def self.weeks: (Integer n) -> Duration

.year(n) ⇒ Duration

Parameters:

Returns:



21
# File 'runtime/snails/duration.rbs', line 21

def self.year: (Integer n) -> Duration

.years(n) ⇒ Duration

Parameters:

Returns:



20
# File 'runtime/snails/duration.rbs', line 20

def self.years: (Integer n) -> Duration

Instance Method Details

#<(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


32
# File 'runtime/snails/duration.rbs', line 32

def <: (untyped other) -> bool

#<=(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


33
# File 'runtime/snails/duration.rbs', line 33

def <=: (untyped other) -> bool

#<=>(other) ⇒ Integer?

order against another Duration or a raw seconds count. Spelled out rather than mixed in from Comparable so every operator is a plain method on this value.

Parameters:

  • other (Object) —

    a Duration or a seconds count

Returns:

  • (Integer, nil) —

    -1, 0, or 1; nil when the other side cannot be compared



147
# File 'runtime/snails/duration.rb', line 147

def <=>: (untyped other) -> Integer

#==(other) ⇒ Boolean

value equality: equal to another Duration or to its own seconds count (1.year == 31556952).

Parameters:

  • other (Object) —

    a Duration or a seconds count

Returns:

  • (Boolean) —

    true when both sides hold the same seconds



136
# File 'runtime/snails/duration.rb', line 136

def ==: (untyped other) -> bool

#>(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


34
# File 'runtime/snails/duration.rbs', line 34

def >: (untyped other) -> bool

#>=(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


35
# File 'runtime/snails/duration.rbs', line 35

def >=: (untyped other) -> bool

#ago ⇒ Time

the instant this span before now; until() is its twin.

Returns:

  • (Time) —

    the current UTC instant shifted back



89
# File 'runtime/snails/duration.rb', line 89

def ago: () -> Time

#from_now ⇒ Time

the instant this span after now; since() is its twin.

Returns:

  • (Time) —

    the current UTC instant shifted forward



100
# File 'runtime/snails/duration.rb', line 100

def from_now: () -> Time

#seconds ⇒ Integer

the span in seconds.

Returns:

  • (Integer) —

    the stored seconds count



127
# File 'runtime/snails/duration.rb', line 127

def seconds: () -> Integer

#since ⇒ Time

Returns:



25
# File 'runtime/snails/duration.rbs', line 25

def since: () -> Time

#to_f ⇒ Float

Returns:

  • (Float)


27
# File 'runtime/snails/duration.rbs', line 27

def to_f: () -> Float

#to_i ⇒ Integer

Returns:



26
# File 'runtime/snails/duration.rbs', line 26

def to_i: () -> Integer

#to_s ⇒ String

the span as its seconds count (30.minutes.to_s is "1800"), which is also what string interpolation prints.

Returns:

  • (String) —

    the seconds count



120
# File 'runtime/snails/duration.rb', line 120

def to_s: () -> String

#until ⇒ Time

Returns:



23
# File 'runtime/snails/duration.rbs', line 23

def until: () -> Time