Class: Krakow::Command::Pub

Inherits:
Krakow::Command show all
Defined in:
lib/krakow/command/pub.rb

Overview

Publish single message

Instance Attribute Summary

Attributes inherited from Krakow::Command

#response

Attributes collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Krakow::Command

#error?, #name, #ok?, response_for

Methods included from Utils::Lazy

included

Methods included from Utils::Logging

level=, #log

Class Method Details

.errorObject



30
31
32
# File 'lib/krakow/command/pub.rb', line 30

def error
  %w(E_INVALID E_BAD_TOPIC E_BAD_MESSAGE E_PUB_FAILED)
end

.okObject



26
27
28
# File 'lib/krakow/command/pub.rb', line 26

def ok
  %w(OK)
end

Instance Method Details

#messageObject

Returns the message attribute.

Returns:

  • (Object)

    the message attribute



16
# File 'lib/krakow/command/pub.rb', line 16

attribute :message, Object, :required => true

#message?TrueClass, FalseClass

Returns truthiness of the message attribute.

Returns:

  • (TrueClass, FalseClass)

    truthiness of the message attribute



16
# File 'lib/krakow/command/pub.rb', line 16

attribute :message, Object, :required => true

#to_lineObject



20
21
22
23
# File 'lib/krakow/command/pub.rb', line 20

def to_line
  msg = message.to_s
  [name, ' ', topic_name, "\n", msg.bytesize, msg].pack('a*a*a*a*l>a*')
end

#topic_nameString

Returns the topic_name attribute.

Returns:

  • (String)

    the topic_name attribute



15
# File 'lib/krakow/command/pub.rb', line 15

attribute :topic_name, String, :required => true

#topic_name?TrueClass, FalseClass

Returns truthiness of the topic_name attribute.

Returns:

  • (TrueClass, FalseClass)

    truthiness of the topic_name attribute



15
# File 'lib/krakow/command/pub.rb', line 15

attribute :topic_name, String, :required => true