Class: Fixnum
Overview
some syntactic sugar for Fixnums… useful for working with Time .. e.g. updated now - 1.week #updated one week ago
Instance Method Summary collapse
-
#days ⇒ Object
(also: #day)
treats the fixnum as a representation of a number of days and returns the total number of seconds represented..
-
#hours ⇒ Object
(also: #hour)
treats the fixnum as a representation of a number of hours and returns the total number of seconds represented..
-
#milliseconds ⇒ Object
treats the fixnum as a representation of a number of milliseconds, returns the approximate total number of seconds represented e.g.
-
#minutes ⇒ Object
(also: #minute)
treats the fixnum as a representation of a number of minutes and returns the total number of seconds represented..
-
#seconds ⇒ Object
(also: #second)
treats the fixnum as a representation of a number of seconds.
-
#weeks ⇒ Object
(also: #week)
treats the fixnum as a representatin of a number of weeks and returns the total number of seconds represented..
-
#within?(r) ⇒ Boolean
true if this number is within the given range.
Instance Method Details
#days ⇒ Object Also known as: day
treats the fixnum as a representation of a number of days and returns the total number of seconds represented.. e.g. 2.days => 172800
1089 1090 1091 |
# File 'lib/streams/activitystreams.rb', line 1089 def days hours * 24 end |
#hours ⇒ Object Also known as: hour
treats the fixnum as a representation of a number of hours and returns the total number of seconds represented.. e.g. 2.hours => 7200
1082 1083 1084 |
# File 'lib/streams/activitystreams.rb', line 1082 def hours minutes * 60 end |
#milliseconds ⇒ Object
treats the fixnum as a representation of a number of milliseconds, returns the approximate total number of seconds represented e.g. 1000.milliseconds => 1 fractional seconds are truncated (rounded down)
1061 1062 1063 |
# File 'lib/streams/activitystreams.rb', line 1061 def milliseconds self / 1000 end |
#minutes ⇒ Object Also known as: minute
treats the fixnum as a representation of a number of minutes and returns the total number of seconds represented.. e.g. 2.minutes => 120, 3.minutes => 180
1075 1076 1077 |
# File 'lib/streams/activitystreams.rb', line 1075 def minutes seconds * 60 end |
#seconds ⇒ Object Also known as: second
treats the fixnum as a representation of a number of seconds
1067 1068 1069 |
# File 'lib/streams/activitystreams.rb', line 1067 def seconds self end |
#weeks ⇒ Object Also known as: week
treats the fixnum as a representatin of a number of weeks and returns the total number of seconds represented.. e.g. 2.weeks => 1209600
1096 1097 1098 |
# File 'lib/streams/activitystreams.rb', line 1096 def weeks days * 7 end |
#within?(r) ⇒ Boolean
true if this number is within the given range
1052 1053 1054 1055 |
# File 'lib/streams/activitystreams.rb', line 1052 def within? r raise ArgumentError if not r.is_a?Range r.include? self end |