Class: CorpPdf::Fields::Radio

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/corp_pdf/fields/radio.rb

Overview

Handles radio button field creation

Instance Attribute Summary collapse

Attributes included from Base

#document, #field_type, #field_value, #metadata, #name, #options

Instance Method Summary collapse

Methods included from Base

#height, #initialize, #page_num, #width, #x, #y

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

#field_obj_numObject (readonly)

Returns the value of attribute field_obj_num.



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

def field_obj_num
  @field_obj_num
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/corp_pdf/fields/radio.rb', line 11

def call
  @field_value = @field_value.to_s.gsub(" ", "")
  group_id = @options[:group_id]
  radio_groups = @document.instance_variable_get(:@radio_groups)
  parent_ref = radio_groups[group_id]

  if parent_ref
    # Subsequent radio button: add widget to existing parent's Kids array
    add_subsequent_widget(parent_ref)
  else
    # First radio button in group: create parent field and first widget
    create_first_widget(group_id, radio_groups)
  end

  true
end