Module: ImgToPdf::PaperSizeParser
- Extended by:
- PaperSizeParser
- Included in:
- PaperSizeParser
- Defined in:
- lib/img_to_pdf/paper_size_parser.rb
Constant Summary collapse
- AVAILABLE_DIRECTIONS =
%i[landscape portrait]
Instance Method Summary collapse
-
#call(s) ⇒ ImgToPdf::Dimension
Parsed paper dimension.
Instance Method Details
#call(s) ⇒ ImgToPdf::Dimension
Returns parsed paper dimension. points.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/img_to_pdf/paper_size_parser.rb', line 12 def call(s) paper_size, direction = *s.split("-") direction = direction.downcase.to_sym if !AVAILABLE_DIRECTIONS.include?(direction) raise ImgToPdf::ParserError, "invalid paper direction: #{s.inspect}" end raw_size_pt = PDF::Core::PageGeometry::SIZES[paper_size.upcase] if !raw_size_pt raise ImgToPdf::ParserError, "invalid paper size: #{s.inspect}" end paper_dimension_pt = ImgToPdf::Dimension.from_array(raw_size_pt) paper_dimension_pt = paper_dimension_pt.justify_direction(direction) return paper_dimension_pt end |