Skip to content

Commit 3280c6d

Browse files
Phil GoochPhil Gooch
authored andcommitted
Response to @jonmagic's comments
* Makes `Page.text()` options a hash where `flags` takes an array of `pdftotext` flags
1 parent ef7a6dd commit 3280c6d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/grim/page.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ def save(path, options={})
4747
# pdf[1].text
4848
# # => "This is text from slide 2.\n\nAnd even more text from slide 2."
4949
#
50-
# pdf[1].text(options=["-table"])
50+
# pdf[1].text(options={flags: ["-table"]})
5151
# Returns a String.
5252
#
53-
def text(options=[])
54-
command = [@pdftotext_path, "-enc", "UTF-8", "-f", @number, "-l", @number, options.join(", "), Shellwords.escape(@pdf.path), "-"].join(' ')
53+
def text(options={flags: []})
54+
command = [@pdftotext_path, "-enc", "UTF-8", "-f", @number, "-l", @number, options[:flags].join(", "), Shellwords.escape(@pdf.path), "-"].join(' ')
5555
Grim.logger.debug { "Running pdftotext command" }
5656
Grim.logger.debug { command }
5757
`#{command}`

spec/lib/grim/page_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
it "should extract tabular data with the -table option" do
5555
pdf = Grim::Pdf.new(fixture_path("table.pdf"))
56-
expect(pdf[0].text(options=["-table"])).to \
56+
expect(pdf[0].text(options={flags: ["-table"]})).to \
5757
include(
5858
" Male 979 (85) 968 (85)\n\n" +
5959
" Female 169 (15) 169 (15)\n")

0 commit comments

Comments
 (0)