Class: PrawnRailsForms::FieldRow

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn-rails-forms/field_row.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.



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

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.



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

def document
  @document
end

#heightObject

Returns the value of attribute height.



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

def height
  @height
end

#unit_widthObject

Returns the value of attribute unit_width.



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

def unit_width
  @unit_width
end

#unitsObject

Returns the value of attribute units.



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

def units
  @units
end

#xObject

Returns the value of attribute x.



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

def x
  @x
end

#yObject

Returns the value of attribute y.



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

def y
  @y
end

Instance Method Details

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



12
13
14
15
16
17
# File 'lib/prawn-rails-forms/field_row.rb', line 12

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

#check_box_field(**args) ⇒ Object



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

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



19
20
21
22
23
24
# File 'lib/prawn-rails-forms/field_row.rb', line 19

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