Module: Pdfsink::TableStrategy

Defined in:
lib/pdfsink/table_strategy.rb

Overview

The table-detection strategies supported by pdfsink-rs.

Each constant holds the string the CLI’s table command expects. Use symbols or strings interchangeably in the public API – TableStrategy.resolve normalizes them.

Examples:

page.tables(strategy: Pdfsink::TableStrategy::TEXT)
page.tables(strategy: :text)  # same thing

Constant Summary collapse

LINES =

Detect cell boundaries from ruling lines.

"lines"
LINES_STRICT =

Like LINES, but only lines that meet at corners delimit cells.

"lines_strict"
TEXT =

Infer boundaries from text alignment when there are no ruling lines.

"text"
EXPLICIT =

Use caller-supplied explicit vertical/horizontal lines.

"explicit"
ALL =

All known strategy names.

[LINES, LINES_STRICT, TEXT, EXPLICIT].freeze

Class Method Summary collapse

Class Method Details

.resolve(name) ⇒ String

Normalize a strategy argument to the string the CLI expects.

Accepts symbols, strings, or nil (nil -> the configured default, falling back to “lines”). Unknown values raise ArgumentError.

Parameters:

  • name (Symbol, String, nil)

Returns:

  • (String)

Raises:

  • (ArgumentError)


36
37
38
39
40
41
42
43
44
45
# File 'lib/pdfsink/table_strategy.rb', line 36

def self.resolve(name)
  name = Pdfsink.configuration.default_table_strategy if name.nil?
  name = LINES if name.nil?

  key = name.to_s.downcase.strip
  return key if ALL.include?(key)

  raise ArgumentError, "Unknown table strategy: #{name.inspect}. " \
                       "Known strategies: #{ALL.join(', ')}"
end