Class: Rsssf::PageReport
- Inherits:
-
Object
- Object
- Rsssf::PageReport
- Defined in:
- lib/rsssf/reports/page.rb
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #build_summary ⇒ Object
-
#initialize(stats, title:) ⇒ PageReport
constructor
A new instance of PageReport.
-
#save(path) ⇒ Object
save report as README.md in repo.
Constructor Details
#initialize(stats, title:) ⇒ PageReport
Returns a new instance of PageReport.
21 22 23 24 |
# File 'lib/rsssf/reports/page.rb', line 21 def initialize( stats, title: ) @stats = stats @title = title end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
19 20 21 |
# File 'lib/rsssf/reports/page.rb', line 19 def title @title end |
Class Method Details
Instance Method Details
#build_summary ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rsssf/reports/page.rb', line 30 def build_summary stats = @stats.sort do |l,r| r.year <=> l.year end header =<<EOS # #{title} football.db RSSSF Archive Data Summary for #{title} EOS ## no longer add last update ## _Last Update: #{Time.now}_ txt = '' txt << header txt << "| File | Authors | Last Updated | Lines (Chars) | Sections |\n" txt << "| :----- | :------- | :----------- | ------------: | :------- |\n" ## note - removed season (no longer tracked here) stats.each do |stat| ## get basename from source url url_path = URI.parse( stat.source ).path basename = File.basename( url_path, File.extname( url_path ) ) ## e.g. duit92.txt or duit92.html => duit92 txt << "| [#{basename}.txt](#{basename}.txt) " txt << "| #{stat.} " txt << "| #{stat.last_updated} " txt << "| #{stat.line_count} (#{stat.char_count}) " txt << "| #{stat.sections.join(', ')} " txt << "|\n" end txt << "\n\n" txt end |
#save(path) ⇒ Object
save report as README.md in repo
27 |
# File 'lib/rsssf/reports/page.rb', line 27 def save( path ) write_text( path, build_summary ); end |