Class: Ucode::Glyphs::EmbeddedFonts::Mutool::Show

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/glyphs/embedded_fonts/mutool/show.rb

Instance Method Summary collapse

Constructor Details

#initialize(runner: SystemRunner.new) ⇒ Show

Returns a new instance of Show.



13
14
15
# File 'lib/ucode/glyphs/embedded_fonts/mutool/show.rb', line 13

def initialize(runner: SystemRunner.new)
  @runner = runner
end

Instance Method Details

#grep(pdf, *obj_ids) ⇒ Object



17
18
19
20
21
22
# File 'lib/ucode/glyphs/embedded_fonts/mutool/show.rb', line 17

def grep(pdf, *obj_ids)
  return "" if obj_ids.empty?

  @runner.run("mutool", "show", "-g", pdf.to_s,
              *obj_ids.map(&:to_s))
end

#stream(pdf, obj_id) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/ucode/glyphs/embedded_fonts/mutool/show.rb', line 24

def stream(pdf, obj_id)
  Tempfile.create("mutool-stream") do |tmp|
    tmp.close
    @runner.run("mutool", "show", "-o", tmp.path, "-b",
                pdf.to_s, obj_id.to_s)
    File.binread(tmp.path).force_encoding("UTF-8")
  end
end