Implement Hashish#to_s
Change-Id: I469a565960125f473e1e3fcf1c9cb9be756ea29e
This commit is contained in:
@@ -60,6 +60,24 @@ class Hashish
|
|||||||
@hash.to_json(obj)
|
@hash.to_json(obj)
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
# Hashishify all the things!
|
# Hashishify all the things!
|
||||||
|
Reference in New Issue
Block a user