Class: PdfTempura::Document::BoxedCharacters

Inherits:
Field::Base
  • Object
show all
Defined in:
lib/pdf_tempura/document/boxed_characters.rb

Defined Under Namespace

Classes: CharacterGroup, SpaceGroup

Instance Attribute Summary collapse

Attributes inherited from Field::Base

#name

Instance Method Summary collapse

Methods inherited from Field::Base

#height, #x, #y

Methods included from Validation

included

Constructor Details

#initialize(name, coordinates, height, options = {}, &block) ⇒ BoxedCharacters

Returns a new instance of BoxedCharacters.



12
13
14
15
16
17
18
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 12

def initialize(name, coordinates, height, options = {}, &block)
  @groups = []

  super name, coordinates, [0, height], options

  instance_eval(&block) if block_given?
end

Instance Attribute Details

#box_spacingObject (readonly)

Returns the value of attribute box_spacing.



4
5
6
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 4

def box_spacing
  @box_spacing
end

#box_widthObject (readonly)

Returns the value of attribute box_width.



4
5
6
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 4

def box_width
  @box_width
end

#coordinatesObject

Returns the value of attribute coordinates.



5
6
7
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 5

def coordinates
  @coordinates
end

#groupsObject (readonly)

Returns the value of attribute groups.



4
5
6
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 4

def groups
  @groups
end

#paddingObject (readonly)

Returns the value of attribute padding.



4
5
6
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 4

def padding
  @padding
end

#text_optionsObject (readonly)

Returns the value of attribute text_options.



4
5
6
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 4

def text_options
  @text_options
end

#truncateObject (readonly) Also known as: truncate?

Returns the value of attribute truncate.



4
5
6
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 4

def truncate
  @truncate
end

Instance Method Details

#characters(characters) ⇒ Object



20
21
22
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 20

def characters(characters)
  @groups << CharacterGroup.new(characters)
end

#dimensionsObject



40
41
42
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 40

def dimensions
  [width, @dimensions[1]]
end

#fieldsObject



32
33
34
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 32

def fields
  @fields ||= generate_text_fields
end

#space(width) ⇒ Object



24
25
26
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 24

def space(width)
  @groups << SpaceGroup.new(width)
end

#supported_charactersObject



28
29
30
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 28

def supported_characters
  @groups.map(&:characters).inject(:+)
end

#widthObject



36
37
38
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 36

def width
  groups.inject(0){ |sum,group| sum + group.width(box_width, box_spacing) }
end