Module: ProMotion::ChaTable

Includes:
Styling, Table::Refreshable
Included in:
ChaTableScreen
Defined in:
lib/cha_work/table/table.rb

Defined Under Namespace

Modules: TableClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#promotion_table_dataObject (readonly)

Returns the value of attribute promotion_table_data.



6
7
8
# File 'lib/cha_work/table/table.rb', line 6

def promotion_table_data
  @promotion_table_data
end

Instance Method Details

#numberOfSectionsInTableView(table_view) ⇒ Object

Cocoa touch methods #################



46
47
48
49
50
51
52
# File 'lib/cha_work/table/table.rb', line 46

def numberOfSectionsInTableView(table_view)
  if self.respond_to?(:section_count)
    section_count
  else
    1
  end
end

#screen_setupObject



17
18
19
# File 'lib/cha_work/table/table.rb', line 17

def screen_setup
  set_up_refreshable
end

#set_up_refreshableObject



21
22
23
24
25
26
27
28
29
# File 'lib/cha_work/table/table.rb', line 21

def set_up_refreshable
  if self.class.respond_to?(:get_refreshable) && self.class.get_refreshable
    if defined?(UIRefreshControl)
      self.make_refreshable(self.class.get_refreshable_params)
    else
      PM.logger.warn "To use the refresh control on < iOS 6, you need to include the CocoaPod 'CKRefreshControl'."
    end
  end
end

#table_dataObject



12
13
14
15
# File 'lib/cha_work/table/table.rb', line 12

def table_data
  PM.logger.warn "@data is require" unless @data
  @data || []
end

#table_viewObject



8
9
10
# File 'lib/cha_work/table/table.rb', line 8

def table_view
  self.view
end

#tableView(table_view, heightForHeaderInSection: index) ⇒ Object

Section view methods



55
56
57
58
59
60
61
# File 'lib/cha_work/table/table.rb', line 55

def tableView(table_view, numberOfRowsInSection:section)
  if self.respond_to?(:row_count)
    row_count(section)
  else
    table_data.length
  end
end

#trigger_action(action, arguments, index_path) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/cha_work/table/table.rb', line 31

def trigger_action(action, arguments, index_path)
  return PM.logger.info "Action not implemented: #{action.to_s}" unless self.respond_to?(action)

  case self.method(action).arity
  when 0 then self.send(action) # Just call the method
  when 2 then self.send(action, arguments, index_path) # Send arguments and index path
  else self.send(action, arguments) # Send arguments
  end
end

#update_section(index, bool = false) ⇒ Object



41
42
43
# File 'lib/cha_work/table/table.rb', line 41

def update_section(index, bool=false)
  self.view.reloadSections(NSIndexSet.indexSetWithIndex(index), withRowAnimation:bool)
end

#update_table_viewObject



95
96
97
# File 'lib/cha_work/table/table.rb', line 95

def update_table_view
  self.view.reloadData
end