class PdfTempura::Document::Field::Base

Attributes

coordinates[R]
dimensions[R]
name[R]

Public Class Methods

new(name, coordinates, dimensions, options = {}) click to toggle source
# File lib/pdf_tempura/document/field/base.rb, line 6
def initialize(name, coordinates, dimensions, options = {})
  @name = name.is_a?(Symbol) ? name.to_s : name
  @coordinates = coordinates
  @dimensions = dimensions

  convert_options_hash(options)
  load_options(options)

  validate!
end

Public Instance Methods

height() click to toggle source
# File lib/pdf_tempura/document/field/base.rb, line 35
def height
  dimensions.last
end
width() click to toggle source
# File lib/pdf_tempura/document/field/base.rb, line 31
def width
  dimensions.first
end
x() click to toggle source
# File lib/pdf_tempura/document/field/base.rb, line 23
def x
  coordinates.first
end
y() click to toggle source
# File lib/pdf_tempura/document/field/base.rb, line 27
def y
  coordinates.last
end

Private Instance Methods

convert_options_hash(options) click to toggle source
# File lib/pdf_tempura/document/field/base.rb, line 45
def convert_options_hash(options)
  if options.is_a?(Hash)
    options.extend(Extensions::Hash::StringifyKeys).stringify_keys!
  else
    raise ArgumentError, "Options must be a hash."
  end
end
load_options(options) click to toggle source
# File lib/pdf_tempura/document/field/base.rb, line 41
def load_options(options)
  raise NotImplementedError, "Implement 'load_options' in your subclass."
end