Class: Numeric
- Includes:
- Duration::Numeric
- Defined in:
- lib/garcon/core_ext/numeric.rb,
lib/garcon/core_ext/time.rb,
lib/garcon/core_ext/duration.rb
Overview
Add #blank? method to Numeric class.
Instance Method Summary collapse
-
#blank? ⇒ FalseClass
Numerics are never blank.
- #clone? ⇒ Boolean
-
#dup! ⇒ Object
Since Numeric is immutable it cannot be duplicated.
- #dup? ⇒ Boolean
-
#time_humanize(include_seconds = false) ⇒ Object
Reports the approximate distance in time between two Time, Date or DateTime objects or integers as seconds.
Methods included from Duration::Numeric
#days, #fortnights, #hours, #minutes, #months, #seconds, #weeks, #years
Instance Method Details
#blank? ⇒ FalseClass
Numerics are never blank
32 33 34 |
# File 'lib/garcon/core_ext/numeric.rb', line 32 def blank? false end |
#dup! ⇒ Object
Since Numeric is immutable it cannot be duplicated. For this reason #try_dup returns self
.
1.dup! #=> 1
41 |
# File 'lib/garcon/core_ext/numeric.rb', line 41 def dup! ; self ; end |
#time_humanize(include_seconds = false) ⇒ Object
Reports the approximate distance in time between two Time, Date or DateTime objects or integers as seconds.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/garcon/core_ext/time.rb', line 214 def time_humanize(include_seconds = false) deta = self deta, seconds = deta.divmod(60) deta, minutes = deta.divmod(60) deta, hours = deta.divmod(24) deta, days = deta.divmod(30) years, months = deta.divmod(12) ret = '' ret << "#{years} years " unless years == 0 ret << "#{months} months " unless months == 0 ret << "#{days} days " unless days == 0 ret << "#{hours} hours " unless hours == 0 ret << "#{minutes} minutes " unless minutes == 0 ret << "#{seconds} seconds" if include_seconds ret.rstrip end |