Class: RubyMotionQuery::AlertAction

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

Constant Summary collapse

VALID_STYLES =
[:default, :destructive, :cancel]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, &block) ⇒ AlertAction

Returns a new instance of AlertAction.



11
12
13
14
15
16
17
# File 'lib/project/alert_action.rb', line 11

def initialize(opts = {}, &block)
  opts     = {title: opts} if opts.is_a? String
  @title   = opts[:title] || "OK" || NSLocalizedString("OK", nil)
  @tag     = opts[:tag] || @title.gsub(/\s+/,"_").downcase.to_sym
  @style   = VALID_STYLES.include?(opts[:style]) ? opts[:style] : VALID_STYLES.first
  @handler = block if block_given?
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



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

def handler
  @handler
end

#styleObject (readonly)

Returns the value of attribute style.



8
9
10
# File 'lib/project/alert_action.rb', line 8

def style
  @style
end

#tagObject (readonly)

Returns the value of attribute tag.



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

def tag
  @tag
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#cancel?Boolean

Returns:

  • (Boolean)


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

def cancel?
  @style == :cancel
end

#default?Boolean

Returns:

  • (Boolean)


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

def default?
  @style == :default
end

#destructive?Boolean

Returns:

  • (Boolean)


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

def destructive?
  @style == :destructive
end