Class: BaseRow

Inherits:
Object
  • Object
show all
Defined in:
lib/project/rows/base_row.rb

Direct Known Subclasses

TextInputRow

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, options) ⇒ BaseRow

Returns a new instance of BaseRow.



4
5
6
7
8
9
10
# File 'lib/project/rows/base_row.rb', line 4

def initialize(key, options)
  @key     = key
  @options = options

  @label = options.fetch(:label, key.to_s.titleize)
  @value = options.fetch(:value, nil)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



2
3
4
# File 'lib/project/rows/base_row.rb', line 2

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



2
3
4
# File 'lib/project/rows/base_row.rb', line 2

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



2
3
4
# File 'lib/project/rows/base_row.rb', line 2

def options
  @options
end

Instance Method Details

#cell_identifierObject



28
29
30
# File 'lib/project/rows/base_row.rb', line 28

def cell_identifier
  cell_type::IDENTIFIER
end

#deallocObject



24
25
26
# File 'lib/project/rows/base_row.rb', line 24

def dealloc
  notification_center.removeObserver(self)
end

#has_value?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/project/rows/base_row.rb', line 32

def has_value?
  cell_type.has_value?
end

#notification_centerObject



12
13
14
# File 'lib/project/rows/base_row.rb', line 12

def notification_center
  NSNotificationCenter.defaultCenter
end

#observe(notification_name, selector) ⇒ Object



20
21
22
# File 'lib/project/rows/base_row.rb', line 20

def observe(notification_name, selector)
  notification_center.addObserver(self, selector: selector, name: notification_name, object: nil)
end

#post(notification) ⇒ Object



16
17
18
# File 'lib/project/rows/base_row.rb', line 16

def post(notification)
  notification_center.postNotificationName(notification, object: self, userInfo: nil)
end

#update_cell(cell) ⇒ Object



36
37
38
39
40
# File 'lib/project/rows/base_row.rb', line 36

def update_cell(cell)
  cell.key         = key
  cell.label       = label
  cell.placeholder = options.fetch(:placeholder, nil)
end