Class: AocCli::Files::Calendar
- Inherits:
-
Object
- Object
- AocCli::Files::Calendar
- Defined in:
- lib/aoc_cli/files.rb
Instance Attribute Summary collapse
-
#cal ⇒ Object
readonly
Returns the value of attribute cal.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #include_leaderboard? ⇒ Boolean
-
#initialize(y: Metafile.get(:year), cal:, stats:) ⇒ Calendar
constructor
A new instance of Calendar.
- #make ⇒ Object
- #title ⇒ Object
- #underline ⇒ Object
Constructor Details
Instance Attribute Details
#cal ⇒ Object (readonly)
Returns the value of attribute cal.
139 140 141 |
# File 'lib/aoc_cli/files.rb', line 139 def cal @cal end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
139 140 141 |
# File 'lib/aoc_cli/files.rb', line 139 def stats @stats end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
139 140 141 |
# File 'lib/aoc_cli/files.rb', line 139 def year @year end |
Instance Method Details
#include_leaderboard? ⇒ Boolean
143 144 145 |
# File 'lib/aoc_cli/files.rb', line 143 def include_leaderboard? Prefs.bool(key:"lb_in_calendar") end |
#make ⇒ Object
152 153 154 155 156 157 158 159 160 |
# File 'lib/aoc_cli/files.rb', line 152 def make <<~file #{title} #{underline} #{cal.data.join("\n")}\n #{stats.data.join("\n") if stats.total_stars > 0 && include_leaderboard?} file end |
#title ⇒ Object
146 147 148 |
# File 'lib/aoc_cli/files.rb', line 146 def title "Year #{year}: #{stats.total_stars}/50 *" end |
#underline ⇒ Object
149 150 151 |
# File 'lib/aoc_cli/files.rb', line 149 def underline "-" * (cal.data[0].to_s.length + 2) end |