class HashString

Create an hash with an array

Public Class Methods

new(string_array) click to toggle source

Initialize an array

@param [Array] string_array It's a string who converted to array

# File lib/generators/ruby_rabbitmq_janus/create_request_generator.rb, line 26
def initialize(string_array)
  @array = string_array
  @hash = {}
end

Public Instance Methods

convert_in_hash() click to toggle source

Create and return an hash

# File lib/generators/ruby_rabbitmq_janus/create_request_generator.rb, line 32
def convert_in_hash
  @hash[@array[0]] = test_string_hash
  @hash
end

Private Instance Methods

format_hash_string() click to toggle source

Transform string to hash

# File lib/generators/ruby_rabbitmq_janus/create_request_generator.rb, line 49
def format_hash_string
  @array.drop(1).join(':').sub('{', '').sub('}', '').split(String::SEP_KEY)
end
test_string_hash() click to toggle source

Test if string is hash

# File lib/generators/ruby_rabbitmq_janus/create_request_generator.rb, line 40
def test_string_hash
  if value.include?('{')
    HashString.new(format_hash_string).convert_in_hash
  else
    value
  end
end
value() click to toggle source

Return the value for hash object

# File lib/generators/ruby_rabbitmq_janus/create_request_generator.rb, line 54
def value
  @array[1]
end