class DymoRender::PageSize

Constants

ALL_SIZES

imageable_area is [Left, Top, Right, Bottom]

Attributes

dimension[R]
id[R]
imageable_area[R]
name[R]
slug[R]

Public Class Methods

by_name(name) click to toggle source
# File lib/dymo_render/page_size.rb, line 64
def self.by_name(name)
  data = ALL_SIZES.find { |s| s[:name] == name }
  new(data) if data
end
new(id: "", name:, dimension:, imageable_area:, slug:) click to toggle source
# File lib/dymo_render/page_size.rb, line 30
def initialize(id: "", name:, dimension:, imageable_area:, slug:)
  @id = id
  @name = name
  @dimension = dimension
  @imageable_area = imageable_area
  @slug = slug
end

Public Instance Methods

margin_bottom() click to toggle source
# File lib/dymo_render/page_size.rb, line 60
def margin_bottom
  dimension[1] - imageable_area[3]
end
margin_left() click to toggle source
# File lib/dymo_render/page_size.rb, line 48
def margin_left
  imageable_area[0]
end
margin_right() click to toggle source
# File lib/dymo_render/page_size.rb, line 56
def margin_right
  dimension[0] - imageable_area[2]
end
margin_top() click to toggle source
# File lib/dymo_render/page_size.rb, line 52
def margin_top
  imageable_area[1]
end
pdf_margin() click to toggle source

pdf_margin returns the page margins as required by Prawn: [top, right, bottom, left]

# File lib/dymo_render/page_size.rb, line 39
def pdf_margin
  [ margin_top, margin_right, margin_bottom, margin_left ]
end
pdf_margin_landscape() click to toggle source

the same as pdf_margin, except rotated 90° to switch to landscape

# File lib/dymo_render/page_size.rb, line 44
def pdf_margin_landscape
  [ margin_left, margin_top, margin_right, margin_bottom ]
end