Class: Doggy::CLI::Mute
- Inherits:
-
Object
- Object
- Doggy::CLI::Mute
- Defined in:
- lib/doggy/cli/mute.rb
Instance Method Summary collapse
-
#initialize(options, ids) ⇒ Mute
constructor
A new instance of Mute.
- #run ⇒ Object
Constructor Details
#initialize(options, ids) ⇒ Mute
Returns a new instance of Mute.
8 9 10 11 |
# File 'lib/doggy/cli/mute.rb', line 8 def initialize(, ids) @options = @ids = ids end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/doggy/cli/mute.rb', line 13 def run monitors = @ids.map { |id| Doggy::Models::Monitor.find(id) } body = {} if @options['duration'] body[:end] = Time.now.utc.to_i + Duration.parse(@options['duration']).to_i end body[:scope] = @options['scope'] if @options['scope'] monitors.each { |monitor| monitor.toggle_mute!('mute', JSON.dump(body)) } end |