Class: Plansheet::MonthlyLaTeXSheet
- Inherits:
-
Object
- Object
- Plansheet::MonthlyLaTeXSheet
show all
- Includes:
- LaTeXMixins
- Defined in:
- lib/plansheet/sheet/monthly.rb
Constant Summary
Constants included
from LaTeXMixins
LaTeXMixins::HARD_NL, LaTeXMixins::SQUARE
Instance Method Summary
collapse
#checkbox_item, #config_file_sanity_check, #itemize_tightlist, #itemline, #minipage, #sanitize_string, #sheet_header, #vbox, #vspace, #writein_line
Constructor Details
#initialize(output_file, config) ⇒ MonthlyLaTeXSheet
Returns a new instance of MonthlyLaTeXSheet.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/plansheet/sheet/monthly.rb', line 7
def initialize(output_file, config)
@config = config || {}
config_file_sanity_check({
"highlevel_items" => Array,
"tags" => Hash
})
str =
str << document do
[
month_line,
highlevel_items,
center do
[
events_minipage,
tags_minipages
].join
end,
monthly_calendar_grid
].join
end
puts "Writing to #{output_file}"
File.write(output_file, str)
end
|
Instance Method Details
#events_minipage ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/plansheet/sheet/monthly.rb', line 46
def events_minipage
minipage("8cm") do
"Events:\n#{
itemize_tightlist do
30.times.map do |n|
itemline(
writein_line("6cm"),
opt: (Date.today + n).strftime("%a %m-%d")
)
end.join.concat("\n")
end
}"
end
end
|
#highlevel_items ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/plansheet/sheet/monthly.rb', line 32
def highlevel_items
itemize_tightlist do
@config["highlevel_items"].map do |i|
itemline("#{i} #{writein_line("5cm")}", opt: SQUARE)
end.join.concat("\n")
end
end
|
#month_line ⇒ Object
75
76
77
|
# File 'lib/plansheet/sheet/monthly.rb', line 75
def month_line
"For the next month: #{Date.today} - #{Date.today + 30}\n\n"
end
|
#monthly_calendar_grid ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/plansheet/sheet/monthly.rb', line 79
def monthly_calendar_grid
<<~GRID
\\begin{tabular}{|#{7.times.map { "p{2cm}" }.join("|")}|}
\\hline
GRID
.concat(
%w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday].join(" & ").concat(HARD_NL)
).concat(
5.times.map do |n|
calendar_grid_line n
end.join(HARD_NL).concat(HARD_NL)
).concat(
<<~GRID
\\hline
\\end{tabular}
GRID
)
end
|
#pretty_tag_name(tag) ⇒ Object
61
62
63
|
# File 'lib/plansheet/sheet/monthly.rb', line 61
def pretty_tag_name(tag)
tag.capitalize.gsub("_", " ")
end
|
#tag_minipage(tag, items = 10) ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'lib/plansheet/sheet/monthly.rb', line 65
def tag_minipage(tag, items = 10)
"#{pretty_tag_name tag}:\n".concat(
itemize_tightlist do
items.times.map do
itemline(writein_line("6cm"), opt: SQUARE)
end.join
end
)
end
|
#tags_minipages ⇒ Object
40
41
42
43
44
|
# File 'lib/plansheet/sheet/monthly.rb', line 40
def tags_minipages
minipage("6.5cm") do
@config["tags"].map { |k, v| tag_minipage k, v }.join
end.concat("\n")
end
|