Class: PdfTempura::Render::Field

Inherits:
Object
  • Object
show all
Includes:
FieldBounds, OptionAccess
Defined in:
lib/pdf_tempura/render/field.rb

Direct Known Subclasses

CharacterField, CheckboxField

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, value, options = {}) ⇒ Field

Returns a new instance of Field.



26
27
28
29
30
# File 'lib/pdf_tempura/render/field.rb', line 26

def initialize(field, value, options = {})
  @field = field
  @value = value
  @options = options
end

Class Method Details

.generate(field, value, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pdf_tempura/render/field.rb', line 7

def self.generate(field, value, options)
  case field
  when Document::CheckboxField
    CheckboxField.new(field, value, options)
  when Document::TextField
    TextField.new(field, value, options)
  when Document::CharacterField
    CharacterField.new(field, value, options)
  when Document::BoxedCharacters
    BoxedCharacters.new(field, value, options)
  when Document::Table
    Table.new(field, value, options)
  when Document::FieldSet
    FieldSet.new(field, value, options)
  else
    raise ArgumentError, "don't know how to handle field kind: #{field.class}"
  end
end

Instance Method Details

#render(pdf) ⇒ Object



32
33
34
35
36
# File 'lib/pdf_tempura/render/field.rb', line 32

def render(pdf)
  set_styling(pdf)
  render_field(pdf)
  render_debug_annotation(pdf) if draw_outlines?
end