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
# 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)
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



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

def cell_identifier
  cell_type::IDENTIFIER
end

#deallocObject



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

def dealloc
  notification_center.removeObserver(self)
end

#has_value?Boolean

Returns:

  • (Boolean)


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

def has_value?
  cell_type.has_value?
end

#notification_centerObject



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

def notification_center
  NSNotificationCenter.defaultCenter
end

#observe(notification_name, selector) ⇒ Object



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

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

#post(notification) ⇒ Object



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

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

#update_cell(cell) ⇒ Object



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

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