Class: PrawnRailsForms::FieldRow

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn-rails-forms.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, height, units, x, y, unit_width) ⇒ FieldRow

Returns a new instance of FieldRow.



8
9
10
11
# File 'lib/prawn-rails-forms.rb', line 8

def initialize(document,height, units, x, y, unit_width)
  @document, @height, @units, @x, @y, @unit_width = 
    document, height, units, x, y, unit_width
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



6
7
8
# File 'lib/prawn-rails-forms.rb', line 6

def document
  @document
end

#heightObject

Returns the value of attribute height.



6
7
8
# File 'lib/prawn-rails-forms.rb', line 6

def height
  @height
end

#unit_widthObject

Returns the value of attribute unit_width.



6
7
8
# File 'lib/prawn-rails-forms.rb', line 6

def unit_width
  @unit_width
end

#unitsObject

Returns the value of attribute units.



6
7
8
# File 'lib/prawn-rails-forms.rb', line 6

def units
  @units
end

#xObject

Returns the value of attribute x.



6
7
8
# File 'lib/prawn-rails-forms.rb', line 6

def x
  @x
end

#yObject

Returns the value of attribute y.



6
7
8
# File 'lib/prawn-rails-forms.rb', line 6

def y
  @y
end

Instance Method Details

#at_height(height, options = {}, &block) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/prawn-rails-forms.rb', line 13

def at_height(height, options = {}, &block)
  @y -= height
  if options[:unit].present?
    @x = options[:unit] * @unit_width
  end
  block.call
  @y += height
end

#check_box_field(**args) ⇒ Object



28
29
30
31
32
# File 'lib/prawn-rails-forms.rb', line 28

def check_box_field(**args)
  start, width, height = field_attributes args
  @document.send :make_check_box_field, start, width, height, **args.except(:width, :height)
  @x += width
end

#text_field(**args) ⇒ Object



22
23
24
25
26
# File 'lib/prawn-rails-forms.rb', line 22

def text_field(**args)
  start, width, height = field_attributes args
  @document.send :make_text_field, start, width, height, **args.except(:width, :height)
  @x += width
end