Class: RubyMotionQuery::AlertAction
- Inherits:
-
Object
- Object
- RubyMotionQuery::AlertAction
- Defined in:
- lib/project/alert_action.rb
Constant Summary collapse
- VALID_STYLES =
[:default, :destructive, :cancel]
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #cancel? ⇒ Boolean
- #default? ⇒ Boolean
- #destructive? ⇒ Boolean
-
#initialize(opts = {}, &block) ⇒ AlertAction
constructor
A new instance of AlertAction.
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
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
9 10 11 |
# File 'lib/project/alert_action.rb', line 9 def handler @handler end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
8 9 10 |
# File 'lib/project/alert_action.rb', line 8 def style @style end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
7 8 9 |
# File 'lib/project/alert_action.rb', line 7 def tag @tag end |
#title ⇒ Object (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
27 28 29 |
# File 'lib/project/alert_action.rb', line 27 def cancel? @style == :cancel end |
#default? ⇒ Boolean
19 20 21 |
# File 'lib/project/alert_action.rb', line 19 def default? @style == :default end |
#destructive? ⇒ Boolean
23 24 25 |
# File 'lib/project/alert_action.rb', line 23 def destructive? @style == :destructive end |