Class: EnglishTime
- Inherits:
-
Object
- Object
- EnglishTime
- Defined in:
- lib/svnx/util/englishtime.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #ago ⇒ Object
- #earlier(totime) ⇒ Object
-
#initialize(time) ⇒ EnglishTime
constructor
A new instance of EnglishTime.
- #since(totime, name) ⇒ Object
Constructor Details
#initialize(time) ⇒ EnglishTime
Returns a new instance of EnglishTime.
10 11 12 |
# File 'lib/svnx/util/englishtime.rb', line 10 def initialize time @time = time end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
8 9 10 |
# File 'lib/svnx/util/englishtime.rb', line 8 def time @time end |
Instance Method Details
#ago ⇒ Object
14 15 16 |
# File 'lib/svnx/util/englishtime.rb', line 14 def ago since Time.new, "ago" end |
#earlier(totime) ⇒ Object
18 19 20 |
# File 'lib/svnx/util/englishtime.rb', line 18 def earlier totime since totime, "earlier" end |
#since(totime, name) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/svnx/util/englishtime.rb', line 22 def since totime, name diff = totime - @time seconds = diff.to_i if units = TimeUtil.new.to_units(seconds) sprintf "%s %s %s (%s)", units.first, units.last, name, @time.strftime("%m/%d %H:%M") else @time.strftime "%Y/%m/%d %H:%M" end end |