Class: Integer
Overview
Extends the Integer class with methods for time durations and comparisons.
Instance Method Summary collapse
-
#day ⇒ Integer
Converts the integer (assumed to be days) into seconds.
-
#hour ⇒ Integer
Converts the integer (assumed to be hours) into seconds.
-
#max(*xs) ⇒ Numeric
Returns the maximum of
selfand the given numeric values. -
#min(*xs) ⇒ Numeric
Returns the minimum of
selfand the given numeric values. -
#minute ⇒ Integer
Converts the integer (assumed to be minutes) into seconds.
-
#month ⇒ Integer
Converts the integer (assumed to be months, approximated as 4 weeks) into seconds.
-
#second ⇒ Integer
Represents the integer as a duration in seconds.
-
#week ⇒ Integer
Converts the integer (assumed to be weeks) into seconds.
-
#year ⇒ Integer
Converts the integer (assumed to be years) into seconds.
Instance Method Details
#day ⇒ Integer
Converts the integer (assumed to be days) into seconds.
177 |
# File 'lib/patch/foobar.rb', line 177 def day; self * 24.hour end |
#hour ⇒ Integer
Converts the integer (assumed to be hours) into seconds.
173 |
# File 'lib/patch/foobar.rb', line 173 def hour; self * 60.minute end |
#max(*xs) ⇒ Numeric
Returns the maximum of self and the given numeric values.
212 213 214 215 |
# File 'lib/patch/foobar.rb', line 212 def max(*xs) xs.push(self) xs.max end |
#min(*xs) ⇒ Numeric
Returns the minimum of self and the given numeric values.
199 200 201 202 |
# File 'lib/patch/foobar.rb', line 199 def min(*xs) xs.push(self) xs.min end |
#minute ⇒ Integer
Converts the integer (assumed to be minutes) into seconds.
169 |
# File 'lib/patch/foobar.rb', line 169 def minute; self * 60.second end |
#month ⇒ Integer
Converts the integer (assumed to be months, approximated as 4 weeks) into seconds.
185 |
# File 'lib/patch/foobar.rb', line 185 def month; self * 4.week end |
#second ⇒ Integer
Represents the integer as a duration in seconds.
165 |
# File 'lib/patch/foobar.rb', line 165 def second; self end |
#week ⇒ Integer
Converts the integer (assumed to be weeks) into seconds.
181 |
# File 'lib/patch/foobar.rb', line 181 def week; self * 7.day end |
#year ⇒ Integer
Converts the integer (assumed to be years) into seconds.
189 |
# File 'lib/patch/foobar.rb', line 189 def year; self * 12.month end |