Module: CorpPdf::Fields::Base

Includes:
Actions::Base
Included in:
Checkbox, Radio, Signature, Text
Defined in:
lib/corp_pdf/fields/base.rb

Overview

Base class for field types with shared functionality

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Actions::Base

#acroform_ref, #apply_patch, #find_page_by_number, #get_object_body_with_patch, #next_fresh_object_number, #patches, #resolver

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



9
10
11
# File 'lib/corp_pdf/fields/base.rb', line 9

def document
  @document
end

#field_typeObject (readonly)

Returns the value of attribute field_type.



9
10
11
# File 'lib/corp_pdf/fields/base.rb', line 9

def field_type
  @field_type
end

#field_valueObject (readonly)

Returns the value of attribute field_value.



9
10
11
# File 'lib/corp_pdf/fields/base.rb', line 9

def field_value
  @field_value
end

#metadataObject (readonly)

Returns the value of attribute metadata.



9
10
11
# File 'lib/corp_pdf/fields/base.rb', line 9

def 
  
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/corp_pdf/fields/base.rb', line 9

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/corp_pdf/fields/base.rb', line 9

def options
  @options
end

Instance Method Details

#heightObject



32
33
34
# File 'lib/corp_pdf/fields/base.rb', line 32

def height
  @options[:height] || 20
end

#initialize(document, name, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/corp_pdf/fields/base.rb', line 11

def initialize(document, name, options = {})
  @document = document
  @name = name
  @options = normalize_hash_keys(options)
   = normalize_hash_keys(@options[:metadata] || {})
  @field_type = determine_field_type
  @field_value = @options[:value] || ""
end

#page_numObject



36
37
38
# File 'lib/corp_pdf/fields/base.rb', line 36

def page_num
  @options[:page] || 1
end

#widthObject



28
29
30
# File 'lib/corp_pdf/fields/base.rb', line 28

def width
  @options[:width] || 100
end

#xObject



20
21
22
# File 'lib/corp_pdf/fields/base.rb', line 20

def x
  @options[:x] || 100
end

#yObject



24
25
26
# File 'lib/corp_pdf/fields/base.rb', line 24

def y
  @options[:y] || 500
end