Implement Hashish#to_s

Change-Id: I469a565960125f473e1e3fcf1c9cb9be756ea29e
This commit is contained in:
Mark Maglana 2014-06-03 11:58:49 -07:00
parent eae591eee9
commit 54a6fde6df
1 changed files with 18 additions and 0 deletions

View File

@ -60,6 +60,24 @@ class Hashish
@hash.to_json(obj)
end
def to_s
str = "{"
@hash.each do |key, value|
if value.kind_of? String
value = "'#{value}'"
elsif value.nil?
value = "nil"
elsif value.kind_of? Array
value = "[#{value.join(", ")}]"
end
str += " #{key}: #{value},"
end
str = str[0...-1] + " }"
str
end
private
# Hashishify all the things!