Class: PdfTempura::Render::BoxedCharacters

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BoxedCharacters.



9
10
11
12
13
14
15
# File 'lib/pdf_tempura/render/boxed_characters.rb', line 9

def initialize(field, value, options = {})
  @field = field
  @options = options
  @value = value ? value.dup : ""

  validate_value_length!
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



7
8
9
# File 'lib/pdf_tempura/render/boxed_characters.rb', line 7

def field
  @field
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/pdf_tempura/render/boxed_characters.rb', line 7

def value
  @value
end

Instance Method Details

#render(pdf) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/pdf_tempura/render/boxed_characters.rb', line 17

def render(pdf)
  characters = value.chars.to_a

  field.fields.each do |field|
    break if characters.empty?
    Field::generate(field, characters.shift, @options).render(pdf)
  end

  render_debug_annotation(pdf) if draw_outlines?
end