class ImgToPdf::Dimension

Public Class Methods

from_array(ary) click to toggle source

@param [Array<(Float, Float)>] ary `[width, height]`. @return ImgToPdf::Dimension parsed.

# File lib/img_to_pdf/dimension.rb, line 7
def from_array(ary)
  return new(width: ary[0], height: ary[1])
end

Public Instance Methods

direction() click to toggle source

@return [:landscape, :portrait] direction of dimension.

# File lib/img_to_pdf/dimension.rb, line 18
def direction
  return width > height ? :landscape : :portrait
end
justify_direction(target_direction) click to toggle source

@param [:landscape, :portrait] direction @return [ImgToPdf::Dimension] justified dimension.

# File lib/img_to_pdf/dimension.rb, line 29
def justify_direction(target_direction)
  return direction == target_direction ? dup : transpose
end
pt_to_in() click to toggle source

points to inches.

@return [ImgToPdf::Dimension] inch dimension.

# File lib/img_to_pdf/dimension.rb, line 36
def pt_to_in
  return self.class.new(width: ImgToPdf::Unit.convert_pt_to_in(width),
                        height: ImgToPdf::Unit.convert_pt_to_in(height))
end
to_a() click to toggle source

@return [Array<(Float, Float)>] array. `[width, height]`.

# File lib/img_to_pdf/dimension.rb, line 13
def to_a
  return [width, height]
end
transpose() click to toggle source

@return [ImgToPdf::Dimension] transposed dimension.

# File lib/img_to_pdf/dimension.rb, line 23
def transpose
  return self.class.new(width: height, height: width)
end