class Formatters::InteropFormatter
Formatter of message into interop dictionary format
Public Class Methods
new(message, msg_content_hashed=false)
click to toggle source
Initialization of interop dictionary formatter
Interop dictionary formatter arguments¶ ↑
- message
-
message to format
Calls superclass method
Formatters::DictFormatter::new
# File lib/formatters/interop_formatter.rb, line 27 def initialize(message, msg_content_hashed=false) super(message, msg_content_hashed) end
Public Instance Methods
format_value(value)
click to toggle source
Format value according to type
Parameters¶ ↑
- value
-
value to format
Returns¶ ↑
value formatted as string
Calls superclass method
Formatters::BasicFormatter#format_value
# File lib/formatters/interop_formatter.rb, line 36 def format_value(value) case value when Float # ab_diff = [{'content': [[-1.3, -1.2999999523162842]]}] value.round(5) else super end end
get_as_interop_dictionary()
click to toggle source
Format message as interop dictionary
Returns¶ ↑
message formatted as interop dictionary
# File lib/formatters/interop_formatter.rb, line 49 def get_as_interop_dictionary() dict_to_return = "" \ + "'redelivered': #{format_value( @message.delivery_count == 0 ? false : true )}, "\ + "'reply-to': #{format_value(@message.reply_to)}, "\ + "'subject': #{format_value(@message.subject)}, "\ + "'content-type': #{format_value(@message.content_type)}, "\ + "'id': #{format_value(@message.id)}, "\ + "'group-id': #{format_value(@message.group_id)}, "\ + "'user-id': #{format_value(@message.user_id)}, "\ + "'correlation-id': #{format_value(@message.correlation_id)}, "\ + "'priority': #{format_value(@message.priority)}, "\ + "'durable': #{format_value(@message.durable)}, "\ + "'ttl': #{format_value(@message.ttl)}, "\ + "'absolute-expiry-time': #{format_value(@message.expires)}, "\ + "'address': #{format_value(@message.address.nil? ? nil : @message.address.sub(%r{^topic://}, ''))}, "\ + "'content-encoding': #{format_value(@message.content_encoding)}, "\ + "'delivery-count': #{format_value(@message.delivery_count)}, "\ + "'first-acquirer': #{format_value(@message.first_acquirer?)}, "\ + "'group-sequence': #{format_value(@message.group_sequence)}, "\ + "'reply-to-group-id': #{format_value(@message.reply_to_group_id)}, "\ + "'to': #{format_value(@message.to)}, "\ + "'properties': #{format_value(@message.properties)}, "\ + "'content': #{ format_value(@msg_content_hashed ? StringUtils.sha1_hash(@message.body) : @message.body) }" return self.class.escape_chars("{#{dict_to_return}}") end
print()
click to toggle source
Prints message formatted as interop dictionary to stdout
# File lib/formatters/interop_formatter.rb, line 80 def print() # Print formatted message to stdout puts get_as_interop_dictionary() end