Class: Motion::Alert

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



5
6
7
# File 'lib/project/motion_alert.rb', line 5

def actions
  @actions
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/project/motion_alert.rb', line 4

def message
  @message
end

#presenterObject

Returns the value of attribute presenter.



7
8
9
# File 'lib/project/motion_alert.rb', line 7

def presenter
  @presenter
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/project/motion_alert.rb', line 3

def title
  @title
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/project/motion_alert.rb', line 6

def type
  @type
end

Class Method Details

.instanceObject



9
10
11
12
# File 'lib/project/motion_alert.rb', line 9

def self.instance
  Dispatch.once { @instance ||= alloc.init }
  @instance
end

.new(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/project/motion_alert.rb', line 14

def self.new(options = {})
  instance.tap do |i|
    i.title = options.fetch(:title, nil)
    i.message = options.fetch(:message, nil)
    i.type = options.fetch(:type, :alert)
    i.presenter = options.fetch(:presenter, UIApplication.sharedApplication.keyWindow.rootViewController)
    i.actions = Option.new
  end
end

Instance Method Details

#selected(index) ⇒ Object



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

def selected(index)
  actions[index].choose
end

#showObject



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

def show
  show_as_controller || show_as_alert || show_as_action_sheet
end