Class: Pechkin::Command::SendData

Inherits:
Base
  • Object
show all
Defined in:
lib/pechkin/command/send_data.rb

Overview

Send data to channel and exit. Uses –preview flag to render message and flush it to STDOUT before sending

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#configuration, #handler, #initialize, #puts, #warn

Constructor Details

This class inherits a constructor from Pechkin::Command::Base

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pechkin/command/send_data.rb', line 10

def execute
  ch, msg = parse_endpoint(options.send_data)

  raise "#{ch}/#{msg} not found" unless handler.message?(ch, msg)

  data = read_data(options.data)

  if options.preview
    puts handler.preview(ch, msg, data)
  else
    handler.handle(ch, msg, data).each do |e|
      puts "* #{e.inspect}"
    end
  end
end

#matches?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/pechkin/command/send_data.rb', line 6

def matches?
  options.send_data
end