Module: HttpStub::Extensions::Core::Hash::Formatted

Instance Method Summary collapse

Instance Method Details

#initialize(hash, key_value_delimiter, entry_delimiter = ", ") ⇒ Object


8
9
10
11
12
# File 'lib/http_stub/extensions/core/hash/formatted.rb', line 8

def initialize(hash, key_value_delimiter, entry_delimiter=", ")
  self.merge!(hash || {})
  @key_value_delimiter = key_value_delimiter
  @entry_delimiter     = entry_delimiter
end

#to_sObject


14
15
16
# File 'lib/http_stub/extensions/core/hash/formatted.rb', line 14

def to_s
  self.map { |key_and_value| key_and_value.map(&:to_s).join(@key_value_delimiter) }.join(@entry_delimiter)
end