Class: PdfTempura::Document::BoxedCharacters
- Inherits:
-
Field::Base
- Object
- Field::Base
- PdfTempura::Document::BoxedCharacters
- Defined in:
- lib/pdf_tempura/document/boxed_characters.rb
Defined Under Namespace
Classes: CharacterGroup, SpaceGroup
Instance Attribute Summary collapse
-
#box_spacing ⇒ Object
readonly
Returns the value of attribute box_spacing.
-
#box_width ⇒ Object
readonly
Returns the value of attribute box_width.
-
#coordinates ⇒ Object
Returns the value of attribute coordinates.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#padding ⇒ Object
readonly
Returns the value of attribute padding.
-
#text_options ⇒ Object
readonly
Returns the value of attribute text_options.
-
#truncate ⇒ Object
(also: #truncate?)
readonly
Returns the value of attribute truncate.
Attributes inherited from Field::Base
Instance Method Summary collapse
- #characters(characters) ⇒ Object
- #dimensions ⇒ Object
- #fields ⇒ Object
-
#initialize(name, coordinates, height, options = {}, &block) ⇒ BoxedCharacters
constructor
A new instance of BoxedCharacters.
- #space(width) ⇒ Object
- #supported_characters ⇒ Object
- #width ⇒ Object
Methods inherited from Field::Base
Methods included from Validation
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, = {}, &block) @groups = [] super name, coordinates, [0, height], instance_eval(&block) if block_given? end |
Instance Attribute Details
#box_spacing ⇒ Object (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_width ⇒ Object (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 |
#coordinates ⇒ Object
Returns the value of attribute coordinates.
5 6 7 |
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 5 def coordinates @coordinates end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
4 5 6 |
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 4 def groups @groups end |
#padding ⇒ Object (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_options ⇒ Object (readonly)
Returns the value of attribute text_options.
4 5 6 |
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 4 def end |
#truncate ⇒ Object (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 |
#dimensions ⇒ Object
40 41 42 |
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 40 def dimensions [width, @dimensions[1]] end |
#fields ⇒ Object
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_characters ⇒ Object
28 29 30 |
# File 'lib/pdf_tempura/document/boxed_characters.rb', line 28 def supported_characters @groups.map(&:characters).inject(:+) end |
#width ⇒ Object
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 |