2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/sarray.rb', line 2
def self.string_arr_to_arr(str)
str << " "
puts str.length
arr = []
main_hash = []
temp_hash = {}
field_1 = ""
field = ""
i = -1
while i < str.length-2
i = i + 1
if ["[","{"].include?(str[i])
temp_hash = {}
field = ""
next
end
if [">","\""].include?(str[i])
next
end
if not ["[","{","}","]"].include?(str[i])
if "#{str[i]}" == "="
field_1 = field
field = ""
next
end
if "#{str[i]}#{str[i+1]}#{str[i+2]}" == ", \""
temp_hash[field_1] = field
field = ""
i = i + 2
next
end
field << str[i]
end
if str[i] == "}"
main_hash << temp_hash
next
end
end
puts "\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>"
puts "Array generation complete\n"
puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"
return main_hash
end
|