Sha256: 99199f034baea47c55b8f06514bb1754a336ee6ec3a2a097cc7b07a96c6901ff

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

# frozen_string_literal: true

require 'doggy/duration'

module Doggy
  class CLI::Mute
    def initialize(options, ids)
      @options = options
      @ids     = ids
    end

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doggy-3.0.0.pre.beta1 lib/doggy/cli/mute.rb