Class: Obst::Chart::DailyChange
- Inherits:
-
Object
- Object
- Obst::Chart::DailyChange
- Defined in:
- lib/obst/chart.rb
Instance Method Summary collapse
-
#initialize(**opts) ⇒ DailyChange
constructor
A new instance of DailyChange.
- #to_s ⇒ Object
Constructor Details
#initialize(**opts) ⇒ DailyChange
Returns a new instance of DailyChange.
33 34 35 36 |
# File 'lib/obst/chart.rb', line 33 def initialize(**opts) pathspec = opts[:cfg]&.dig_any(['pathspec'], ['chart_daily_change', 'pathspec']) @daily = Obst::GroupByDays.new(C: opts[:C], pathspec: pathspec).lazy end |
Instance Method Details
#to_s ⇒ Object
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/obst/chart.rb', line 38 def to_s labels = [] datas = {a: [], m: [], d: [], nil => []} @daily.take(28 * 3).each do |record| labels << record.date_wday datas.each_value{ |data| data << 0 } record.file_changes.each_value do |changes| datas[changes.final][-1] += 1 end end <<~EOF # Daily change ```chart type: line width: 98% legendPosition: bottom labels: #{labels.reverse!} series: - title: del data: #{datas[:d].reverse!} - title: nil data: #{datas[nil].reverse!} - title: mod data: #{datas[:m].reverse!} - title: new data: #{datas[:a].reverse!} ``` EOF end |