Sha256: 8256521808c68f889fda444887579a48bcb6a91c25f7770cbf293bfd991bef1b

Contents?: true

Size: 570 Bytes

Versions: 2

Compression:

Stored size: 570 Bytes

Contents

# encoding: utf-8
# 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

2 entries across 2 versions & 1 rubygems

Version Path
doggy-2.1.1 lib/doggy/cli/mute.rb
doggy-2.1.0 lib/doggy/cli/mute.rb