Class: Krakow::Command::Mpub

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

Overview

Publish multiple messages

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



32
33
34
# File 'lib/krakow/command/mpub.rb', line 32

def error
  %w(E_INVALID E_BAD_TOPIC E_BAD_BODY E_BAD_MESSAGE E_MPUB_FAILED)
end

.okObject



28
29
30
# File 'lib/krakow/command/mpub.rb', line 28

def ok
  %w(OK)
end

Instance Method Details

#messagesArray

Returns the messages attribute.

Returns:

  • (Array)

    the messages attribute



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

attribute :messages, Array, :required => true

#messages?TrueClass, FalseClass

Returns truthiness of the messages attribute.

Returns:

  • (TrueClass, FalseClass)

    truthiness of the messages attribute



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

attribute :messages, Array, :required => true

#to_lineObject



19
20
21
22
23
24
25
# File 'lib/krakow/command/mpub.rb', line 19

def to_line
  formatted_messages = messages.map do |message|
    message = message.to_s
    [message.bytesize, message].pack('l>a*')
  end.join
  [name, ' ', topic_name, "\n", formatted_messages.bytesize, messages.size, formatted_messages].pack('a*a*a*a*l>l>a*')
end

#topic_nameString

Returns the topic_name attribute.

Returns:

  • (String)

    the topic_name attribute



15
# File 'lib/krakow/command/mpub.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/mpub.rb', line 15

attribute :topic_name, String, :required => true