Class: Snails::Duration
- 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
- .day(n) ⇒ Duration
- .days(n) ⇒ Duration
- .fortnight(n) ⇒ Duration
- .fortnights(n) ⇒ Duration
- .hour(n) ⇒ Duration
- .hours(n) ⇒ Duration
- .minute(n) ⇒ Duration
- .minutes(n) ⇒ Duration
- .month(n) ⇒ Duration
- .months(n) ⇒ Duration
- .second(n) ⇒ Duration
-
.seconds(n) ⇒ Duration
a span of
nunits. - .week(n) ⇒ Duration
- .weeks(n) ⇒ Duration
- .year(n) ⇒ Duration
- .years(n) ⇒ Duration
Instance Method Summary collapse
- #<(other) ⇒ Boolean
- #<=(other) ⇒ Boolean
-
#<=>(other) ⇒ Integer?
order against another Duration or a raw seconds count.
-
#==(other) ⇒ Boolean
value equality: equal to another Duration or to its own seconds count (
1.year == 31556952). - #>(other) ⇒ Boolean
- #>=(other) ⇒ Boolean
-
#ago ⇒ Time
the instant this span before now;
until()is its twin. -
#from_now ⇒ Time
the instant this span after now;
since()is its twin. -
#initialize(seconds) ⇒ Duration
constructor
A new instance of Duration.
-
#seconds ⇒ Integer
the span in seconds.
- #since ⇒ Time
- #to_f ⇒ Float
- #to_i ⇒ Integer
-
#to_s ⇒ String
the span as its seconds count (
30.minutes.to_sis"1800"), which is also what string interpolation prints. - #until ⇒ Time
Constructor Details
#initialize(seconds) ⇒ Duration
Returns a new instance of Duration.
5 |
# File 'runtime/snails/duration.rbs', line 5
def initialize: (Integer seconds) -> void
|
Class Method Details
.day(n) ⇒ Duration
13 |
# File 'runtime/snails/duration.rbs', line 13
def self.day: (Integer n) -> Duration
|
.days(n) ⇒ Duration
12 |
# File 'runtime/snails/duration.rbs', line 12
def self.days: (Integer n) -> Duration
|
.fortnight(n) ⇒ Duration
17 |
# File 'runtime/snails/duration.rbs', line 17
def self.fortnight: (Integer n) -> Duration
|
.fortnights(n) ⇒ Duration
16 |
# File 'runtime/snails/duration.rbs', line 16
def self.fortnights: (Integer n) -> Duration
|
.hour(n) ⇒ Duration
11 |
# File 'runtime/snails/duration.rbs', line 11
def self.hour: (Integer n) -> Duration
|
.hours(n) ⇒ Duration
10 |
# File 'runtime/snails/duration.rbs', line 10
def self.hours: (Integer n) -> Duration
|
.minute(n) ⇒ Duration
9 |
# File 'runtime/snails/duration.rbs', line 9
def self.minute: (Integer n) -> Duration
|
.minutes(n) ⇒ Duration
8 |
# File 'runtime/snails/duration.rbs', line 8
def self.minutes: (Integer n) -> Duration
|
.month(n) ⇒ Duration
19 |
# File 'runtime/snails/duration.rbs', line 19
def self.month: (Integer n) -> Duration
|
.months(n) ⇒ Duration
18 |
# File 'runtime/snails/duration.rbs', line 18
def self.months: (Integer n) -> Duration
|
.second(n) ⇒ Duration
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.
22 |
# File 'runtime/snails/duration.rb', line 22
def self.seconds: (Integer n) -> Duration
|
.week(n) ⇒ Duration
15 |
# File 'runtime/snails/duration.rbs', line 15
def self.week: (Integer n) -> Duration
|
.weeks(n) ⇒ Duration
14 |
# File 'runtime/snails/duration.rbs', line 14
def self.weeks: (Integer n) -> Duration
|
.year(n) ⇒ Duration
21 |
# File 'runtime/snails/duration.rbs', line 21
def self.year: (Integer n) -> Duration
|
.years(n) ⇒ Duration
20 |
# File 'runtime/snails/duration.rbs', line 20
def self.years: (Integer n) -> Duration
|
Instance Method Details
#<(other) ⇒ Boolean
32 |
# File 'runtime/snails/duration.rbs', line 32
def <: (untyped other) -> bool
|
#<=(other) ⇒ 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.
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).
136 |
# File 'runtime/snails/duration.rb', line 136
def ==: (untyped other) -> bool
|
#>(other) ⇒ Boolean
34 |
# File 'runtime/snails/duration.rbs', line 34
def >: (untyped other) -> bool
|
#>=(other) ⇒ 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.
89 |
# File 'runtime/snails/duration.rb', line 89
def ago: () -> Time
|
#from_now ⇒ Time
the instant this span after now; since() is its twin.
100 |
# File 'runtime/snails/duration.rb', line 100
def from_now: () -> Time
|
#seconds ⇒ Integer
the span in seconds.
127 |
# File 'runtime/snails/duration.rb', line 127
def seconds: () -> Integer
|
#to_f ⇒ Float
27 |
# File 'runtime/snails/duration.rbs', line 27
def to_f: () -> Float
|
#to_s ⇒ String
the span as its seconds count (30.minutes.to_s is "1800"), which is
also what string interpolation prints.
120 |
# File 'runtime/snails/duration.rb', line 120
def to_s: () -> String
|