Class: OrganizzeForm::Form

Inherits:
Object
  • Object
show all
Defined in:
lib/organizze-form/form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeForm

Returns a new instance of Form.



5
6
7
8
# File 'lib/organizze-form/form.rb', line 5

def initialize
  @sections = []
  @uuid = NSUUID.alloc.init.UUIDString
end

Instance Attribute Details

#sectionsObject (readonly)

Returns the value of attribute sections.



3
4
5
# File 'lib/organizze-form/form.rb', line 3

def sections
  @sections
end

#uuidObject (readonly)

Returns the value of attribute uuid.



3
4
5
# File 'lib/organizze-form/form.rb', line 3

def uuid
  @uuid
end

Instance Method Details

#cellFor(tableView, indexPath) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/organizze-form/form.rb', line 16

def cellFor(tableView, indexPath)
  @tableView ||= WeakRef.new(tableView)
  section = @sections[indexPath.section]
  row = section.rows[indexPath.row]
  cell_id = "form-cell-#{@uuid}-#{indexPath.section}-#{indexPath.row}".freeze
  (tableView.dequeueReusableCellWithIdentifier(cell_id) || UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: cell_id)).tap do |cell|
    row.setup_cell(cell)
  end
end

#section(&block) ⇒ Object



10
11
12
13
14
# File 'lib/organizze-form/form.rb', line 10

def section(&block)
  _section = Section.new
  @sections << _section
  block.call _section
end