Module: PrettyFace::Formatter::Formatting
- Included in:
- ReportFeature
- Defined in:
- lib/pretty_face/formatter/report.rb
Instance Method Summary collapse
- #directory_prefix_for(source = nil) ⇒ Object
- #formatted_duration(duration) ⇒ Object
- #image_tag_for(status, source = nil) ⇒ Object
- #separator ⇒ Object
- #summary_percent(number, total) ⇒ Object
- #table_image_for(status, source = nil) ⇒ Object
Instance Method Details
#directory_prefix_for(source = nil) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/pretty_face/formatter/report.rb', line 28 def directory_prefix_for(source=nil) dir = '' back_dir = source.count(separator) if source back_dir.times do dir += "..#{separator}" end dir end |
#formatted_duration(duration) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/pretty_face/formatter/report.rb', line 10 def formatted_duration(duration) m, s = duration.divmod(60) "#{m}m#{'%.3f' % s}s" rescue "N m Ns" end |
#image_tag_for(status, source = nil) ⇒ Object
17 18 19 20 |
# File 'lib/pretty_face/formatter/report.rb', line 17 def image_tag_for(status, source=nil) dir = "#{directory_prefix_for(source)}images" "<img src=\"#{dir}/#{status}.png\" alt=\"#{status}\" title=\"#{status}\">" end |
#separator ⇒ Object
37 38 39 |
# File 'lib/pretty_face/formatter/report.rb', line 37 def separator File::ALT_SEPARATOR || File::SEPARATOR end |
#summary_percent(number, total) ⇒ Object
5 6 7 8 |
# File 'lib/pretty_face/formatter/report.rb', line 5 def summary_percent(number, total) percent = (number.to_f / total) * 100 "#{number} <span class=\"percentage\">(#{'%.1f' % percent}%)</span>" end |
#table_image_for(status, source = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/pretty_face/formatter/report.rb', line 22 def table_image_for(status, source=nil) dir = "#{directory_prefix_for(source)}images" "<img src=\"#{dir}/table_#{status}.png\" alt=\"#{status}\" title=\"#{status}\">" end |