Class: KPM::Formatter::VersionFormatter
- Inherits:
-
Object
- Object
- KPM::Formatter::VersionFormatter
- Defined in:
- lib/kpm/formatter.rb
Overview
Used for the version map
Instance Method Summary collapse
- #format_sha(sha) ⇒ Object
-
#initialize(label, versions) ⇒ VersionFormatter
constructor
A new instance of VersionFormatter.
- #label ⇒ Object
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(label, versions) ⇒ VersionFormatter
Returns a new instance of VersionFormatter.
41 42 43 44 |
# File 'lib/kpm/formatter.rb', line 41 def initialize(label, versions) @label = label @versions = versions end |
Instance Method Details
#format_sha(sha) ⇒ Object
58 59 60 61 |
# File 'lib/kpm/formatter.rb', line 58 def format_sha(sha) return "[???]" if sha.nil? "[#{sha[0..5]}..]" end |
#label ⇒ Object
54 55 56 |
# File 'lib/kpm/formatter.rb', line 54 def label "#{@label.to_s.upcase.gsub(/_/, ' ')} sha1=[], def=(*), del=(x)" end |
#size ⇒ Object
46 47 48 |
# File 'lib/kpm/formatter.rb', line 46 def size to_s.size end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/kpm/formatter.rb', line 50 def to_s @versions.map { |q| sha1=format_sha(q[:sha1]); disabled=""; disabled="(x)" if q[:is_disabled]; default=""; default="(*)" if q[:is_default]; "#{q[:version]}#{sha1}#{default}#{disabled}" }.join(", ") end |