Class: AocCli::Tools::Convert
Instance Attribute Summary collapse
Attributes inherited from Request
#base, #day, #page, #ua, #user, #year
Instance Method Summary
collapse
Methods inherited from Request
#initialize
Instance Attribute Details
Returns the value of attribute input.
45
46
47
|
# File 'lib/aoc_cli/tools.rb', line 45
def input
@input
end
|
Instance Method Details
#array ⇒ Object
46
47
48
|
# File 'lib/aoc_cli/tools.rb', line 46
def array
input.split("\n")
end
|
#chunk(f:, t:, t_off: 0, f_off: 0) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/aoc_cli/tools.rb', line 49
def chunk(f:, t:, t_off:0, f_off:0)
pt1 = array.index {|l| l =~ /#{f}/} + t_off
pt2 = array.rindex{|l| l =~ /#{t}/} + f_off
@input = array.slice(pt1, pt2 - pt1).join("\n")
self
end
|
#md ⇒ Object
61
62
63
64
|
# File 'lib/aoc_cli/tools.rb', line 61
def md
PandocRuby.new(input, {f: html, t: :gfm},
md_head, md_ref).convert
end
|
#plain ⇒ Object
58
59
60
|
# File 'lib/aoc_cli/tools.rb', line 58
def plain
PandocRuby.new(input, f: html, t: :plain).convert
end
|
#raw ⇒ Object
55
56
57
|
# File 'lib/aoc_cli/tools.rb', line 55
def raw
input.split("\n").join("\n")
end
|