glib 0.0.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/glib-main.rb +86 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b077e0812e4842f9d98b58770561d78492617156
4
- data.tar.gz: 45b1e631e5e3cc35c5407b184fbc36ca2d909d51
3
+ metadata.gz: c6f946d967a12279b9a6ea513b26d0ae3de87893
4
+ data.tar.gz: 439c69aadc63d4261be1b60278afcd4933ec8fe1
5
5
  SHA512:
6
- metadata.gz: a347dee040ca8a0eeb6438ad5de94b7ff4252b8902fcb529b8e4490b37af5c8748bce246d1459dacf49f773663d279c4f904e2ce4695d77fbe4bd298a96540eb
7
- data.tar.gz: 8eee8fbb7b224f327a9daef0641fea0af50332aa473166c656a45095799951b1a8fd9e5aeba56ad5fa5bd1a03384563ec9ffcf8282fddf496371c213a10378b9
6
+ metadata.gz: 110e3145801b8688ce516f57ba20eb77f60fc4926ce5c9914e585154bac66f2bfe4b5f4037823a714571da06233ded9f094ac2ac142dad27ef00e014288e8abf
7
+ data.tar.gz: 32805f4e76362285e6de2b4139f74b46081715f4586056e4e53edc1c1e44e0e07b24b83f86aff810ad60214f8b2e3fe3066d9191319e6a070d31f81c81e8c664
data/lib/glib-main.rb ADDED
@@ -0,0 +1,86 @@
1
+ module Glib
2
+ def self.isodd?(input)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Vian
@@ -17,6 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/glib-array.rb
20
+ - lib/glib-main.rb
20
21
  - lib/glib.rb
21
22
  homepage: http://rubygems.org/gems/glib
22
23
  licenses: