Module: Booklet
- Defined in:
- lib/booklet.rb,
lib/booklet/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
Instance Method Details
#pages(pdf) ⇒ Object
10 11 12 |
# File 'lib/booklet.rb', line 10 def pages(pdf) `pdftk #{pdf} dump_data`.split("\n").select { |l| l.start_with? "NumberOfPages:" }[0].split[1].to_i end |
#quire_all(p) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/booklet.rb', line 23 def quire_all(p) (1..p).to_a.map { |i| case i % 4 when 1 then p - (i-1)/2 when 2 then i/2 when 3 then (i+1)/2 else p - i/2 + 1 end }.join(" ") end |
#quire_each(p) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/booklet.rb', line 14 def quire_each(p) (1..p).to_a.map { |i| case i % 4 when 1 then i + 3 else i - 1 end }.join(" ") end |
#run(cmd) ⇒ Object
5 6 7 8 |
# File 'lib/booklet.rb', line 5 def run(cmd) puts "> #{cmd}" `#{cmd}` end |