-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash.rb
More file actions
67 lines (52 loc) · 1.16 KB
/
hash.rb
File metadata and controls
67 lines (52 loc) · 1.16 KB
1
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
63
64
65
66
#!/usr/bin/ruby
END {
langsObj1 = Langs.new()
langsObj1::output
## Return
}
class Langs
@@input = Array(0..12)
@@input = "Java", "C#", "SQL", "TypeScript", "Python", "Ruby"
@@iterating = 0
@@iterArray = nil
@@newLangs = Array.new()
#puts @@input
def initialize
@langs = @@input
@langs = @langs.reverse
#Swaping Elemen@ts By Id and by Search for index
@langs[2], @langs[3] = @langs[3], @langs[2]
@java = @langs.index("Java")
@ts = @langs.index("TypeScript")
@langs[@java], @langs[@ts] = @langs[@ts], @langs[@java]
## function call
convert
end
def convert
for each in @@input
each = each.downcase
each = each.upcase
each = each.capitalize
if each == ("Sql" || "sql" || "sql" ) then
each = each.upcase
end
if each.include?("s" || "S") then
letter = each["s"]
each[letter] = letter.upcase
end
@language = each
@@newLangs << each
@@iterating += 1
end
@@iterArray = Array(1..@@iterating)
end
def output
counter = 0
loop do
printf "%-20s", @@newLangs[counter]
printf "%s \n", @@iterArray[counter]
counter += 1
break if counter == @@newLangs.length
end
end
end