Class: Snooze::Button
- Inherits:
-
Object
- Object
- Snooze::Button
- Defined in:
- lib/snooze/button.rb
Instance Attribute Summary collapse
-
#clock_id ⇒ Object
readonly
Returns the value of attribute clock_id.
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(clock_id, options = {}) ⇒ Button
constructor
A new instance of Button.
-
#snooze! ⇒ Object
Send snooze! or ping! to Snooze.
-
#with_backtrace(&block) ⇒ Object
With backtrace capturing do.
Constructor Details
#initialize(clock_id, options = {}) ⇒ Button
Returns a new instance of Button.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/snooze/button.rb', line 5 def initialize(clock_id, = {}) @clock_id = clock_id @dry_run = [:dry_run] || false @method = :snooze! @verbose = [:verbose] || false if @dry_run @method = :ping! @verbose = true end end |
Instance Attribute Details
#clock_id ⇒ Object (readonly)
Returns the value of attribute clock_id.
3 4 5 |
# File 'lib/snooze/button.rb', line 3 def clock_id @clock_id end |
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
3 4 5 |
# File 'lib/snooze/button.rb', line 3 def dry_run @dry_run end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/snooze/button.rb', line 3 def method @method end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
3 4 5 |
# File 'lib/snooze/button.rb', line 3 def verbose @verbose end |
Instance Method Details
#snooze! ⇒ Object
Send snooze! or ping! to Snooze
18 19 20 21 |
# File 'lib/snooze/button.rb', line 18 def snooze! log "Sending #{@method} to Snooze.io" handle_post_response { Snooze::Post.send(@method, @clock_id) } end |
#with_backtrace(&block) ⇒ Object
With backtrace capturing do
24 25 26 27 28 29 30 31 32 |
# File 'lib/snooze/button.rb', line 24 def with_backtrace(&block) begin log "Yielding backtrace block" yield if block_given? Snooze::Post.snooze! rescue Exception => detail handle_post_response { Snooze::Post.exception!(@clock_id, detail.backtrace.join("\n ")) } end end |