Class: Rsssf::ScheduleReport
- Inherits:
-
Object
- Object
- Rsssf::ScheduleReport
- Defined in:
- lib/rsssf/reports/schedule.rb
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #build_summary ⇒ Object
-
#initialize(stats, opts) ⇒ ScheduleReport
constructor
A new instance of ScheduleReport.
- #save(path) ⇒ Object
Constructor Details
#initialize(stats, opts) ⇒ ScheduleReport
Returns a new instance of ScheduleReport.
9 10 11 12 13 14 |
# File 'lib/rsssf/reports/schedule.rb', line 9 def initialize( stats, opts ) @stats = stats @opts = opts @title = opts[:title] || 'Your Title Here' end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/rsssf/reports/schedule.rb', line 7 def title @title end |
Instance Method Details
#build_summary ⇒ Object
23 24 25 26 27 28 29 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 |
# File 'lib/rsssf/reports/schedule.rb', line 23 def build_summary ## sort start by season (latest first) than by name (e.g. 1-bundesliga, cup, etc.) stats = @stats.sort do |l,r| v = r.season <=> l.season v = l.filename <=> r.filename if v == 0 ## same season v end header =<<EOS # #{title} football.db RSSSF (Rec.Sport.Soccer Statistics Foundation) Archive Data for #{title} _Last Update: #{Time.now}_ EOS =<<EOS ## Questions? Comments? Send them along to the [Open Sports & Friends Forum](http://groups.google.com/group/opensport). Thanks! EOS txt = '' txt << header txt << "| Season | League, Cup | Rounds |\n" txt << "| :----- | :---------- | -----: |\n" stats.each do |stat| txt << "| #{stat.season} " txt << "| [#{stat.filename}](#{stat.path}/#{stat.filename}) " txt << "| #{stat.rounds} " txt << "|\n" end txt << "\n\n" txt << txt end |
#save(path) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rsssf/reports/schedule.rb', line 16 def save( path ) ### save report as README.md in repo File.open( path, 'w' ) do |f| f.write build_summary end end |