glib 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/glib.rb +2 -86
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b077e0812e4842f9d98b58770561d78492617156
|
4
|
+
data.tar.gz: 45b1e631e5e3cc35c5407b184fbc36ca2d909d51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a347dee040ca8a0eeb6438ad5de94b7ff4252b8902fcb529b8e4490b37af5c8748bce246d1459dacf49f773663d279c4f904e2ce4695d77fbe4bd298a96540eb
|
7
|
+
data.tar.gz: 8eee8fbb7b224f327a9daef0641fea0af50332aa473166c656a45095799951b1a8fd9e5aeba56ad5fa5bd1a03384563ec9ffcf8282fddf496371c213a10378b9
|
data/lib/glib.rb
CHANGED
@@ -1,86 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return input % 2 != 0
|
4
|
-
end
|
5
|
-
|
6
|
-
|
7
|
-
def self.iseven?(input)
|
8
|
-
return input % 2 == 0
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
def self.greatest(array)
|
13
|
-
if not array.kind_of?(Array) then raise TypeError end
|
14
|
-
greatest_index = 0
|
15
|
-
for i in 0..array.length - 1
|
16
|
-
if array[i] > array[greatest_index]
|
17
|
-
greatest_index = i
|
18
|
-
end
|
19
|
-
end
|
20
|
-
return greatest_index
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
def self.smallest(array)
|
25
|
-
if not array.kind_of?(Array) then raise TypeError end
|
26
|
-
smallest_index = 0
|
27
|
-
for i in 1..array.length - 1
|
28
|
-
if array[i] < array[smallest_index]
|
29
|
-
smallest_index = i
|
30
|
-
end
|
31
|
-
end
|
32
|
-
return smallest_index
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
def self.normalize(array, char = ",")
|
37
|
-
if not array.kind_of?(Array) then raise TypeError end
|
38
|
-
concat = ""
|
39
|
-
for i in 0..array.length - 1
|
40
|
-
concat = concat + array[i] + char
|
41
|
-
end
|
42
|
-
return concat[0..-2]
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.readconfig(path)
|
46
|
-
if not File.exist?(path) then raise NoMethodError end
|
47
|
-
lines = File.readlines(path)
|
48
|
-
config = {}
|
49
|
-
lines.each do |line|
|
50
|
-
key, value = line.split(": ")
|
51
|
-
config.merge({key => value})
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.tableprint(array)
|
56
|
-
if not array.kind_of?(Array) then raise TypeError end
|
57
|
-
long = 0
|
58
|
-
for i in 0..array.length - 1
|
59
|
-
for j in 0..array[i].length - 1
|
60
|
-
if array[i][j].to_s.length > long
|
61
|
-
long = array[i][j].to_s.length
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
for i in 0..array.length - 1
|
67
|
-
for j in 0..array[i].length - 1
|
68
|
-
spaces = " "
|
69
|
-
for k in 1..long - array[i][j].to_s.length
|
70
|
-
spaces = spaces + " "
|
71
|
-
end
|
72
|
-
print array[i][j].to_s + spaces
|
73
|
-
end
|
74
|
-
puts ""
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def self.uniform(array)
|
79
|
-
if not array.kind_of?(Array) then raise TypeError end
|
80
|
-
tot = array.length
|
81
|
-
for i in 1..array.length - 1
|
82
|
-
if array[i] == array[0] then tot-=1 end
|
83
|
-
end
|
84
|
-
return tot == 0
|
85
|
-
end
|
86
|
-
end
|
1
|
+
require "glib-main"
|
2
|
+
require "glib-array"
|