Class: Repofetch::TimespanStat

Inherits:
Stat
  • Object
show all
Includes:
ActionView::Helpers::DateHelper
Defined in:
lib/repofetch/timespan_stat.rb

Overview

Timespan stat for “x units ago” stats.

Instance Attribute Summary

Attributes inherited from Stat

#emoji, #label, #theme, #value

Instance Method Summary collapse

Methods inherited from Stat

#format, #initialize, #style_label, #style_label!, #to_s

Constructor Details

This class inherits a constructor from Repofetch::Stat

Instance Method Details

#format_value(now = nil) ⇒ Object

Formats the value as “x units ago”.



11
12
13
14
# File 'lib/repofetch/timespan_stat.rb', line 11

def format_value(now = nil)
  now = Time.now if now.nil?
  "#{distance_of_time_in_words(@value, now)} ago"
end