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
11
# File 'lib/project/rows/base_row.rb', line 4

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

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

Instance Attribute Details

#iconObject (readonly)

Returns the value of attribute icon.



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

def icon
  @icon
end

#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



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

def cell_identifier
  cell_type::IDENTIFIER
end

#deallocObject



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

def dealloc
  notification_center.removeObserver(self)
end

#has_value?Boolean

Returns:

  • (Boolean)


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

def has_value?
  cell_type.has_value?
end

#notification_centerObject



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

def notification_center
  NSNotificationCenter.defaultCenter
end

#observe(notification_name, selector) ⇒ Object



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

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

#post(notification) ⇒ Object



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

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

#update_cell(cell) ⇒ Object



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

def update_cell(cell)
  cell.key   = key
  cell.label = label
  cell.icon  = icon
end