glib 0.0.3 → 0.0.4

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.rb +99 -25
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 778da817a87ce70e6b25507daa72af4b20227480
4
- data.tar.gz: 7d9c2b9c32f8fab67ccaa4854c9914e3ba509658
3
+ metadata.gz: abbb733d5e5669851b78381f898028c292ff806a
4
+ data.tar.gz: 896e51633e1943c96484a4068f3c14f5187c8f78
5
5
  SHA512:
6
- metadata.gz: 4f3977990d226fe56e1c76267fa3367bee37669baf811a3d905a32cb7b4e5cfad9a989812d75b3ead91de5bec7b6de2534b5cf3d2c40dc34a4723ef5ec901fa0
7
- data.tar.gz: fa37cfa74a3e2312210b9641fbd14e04ab2c6f757a5d310dc90d3d03dd335cbef895fd8a6f1a2ba9beea005fe1087500df61dcb4398c98c66c20553ca025f37d
6
+ metadata.gz: d4673c9d60b3764b6c1fe51a893c65e41c2fa394566141484fec9014587118962a1a966bf1daa111a338cc2fcb73117d1c4cdf0d94c6eda73a7aec420c6052be
7
+ data.tar.gz: c26bcf5eb5c97a4917ee51e1d48d789c9098be4e3095cdc5abc92246f2ecf2b76f5eba03bb720e2ca02deefc5871a98029adcffa227ea6667ad73b712ed9ab7b
data/lib/glib.rb CHANGED
@@ -1,31 +1,16 @@
1
1
  module Glib
2
- def self.shift(array, index)
3
- if not array.kind_of?(Array) then raise TypeError, "expected: Array" end
4
- array.delete_at(index)
5
- newarray = []
6
- for i in 0..array.length - 1
7
- if array[i] != nil
8
- newarray.push(array[i])
9
- end
10
- end
11
- return newarray
12
- end
13
2
  def self.isodd?(input)
14
- if input % 2 != 0
15
- return true
16
- else
17
- return false
18
- end
3
+ return input % 2 != 0
19
4
  end
5
+
6
+
20
7
  def self.iseven?(input)
21
- if input % 2 == 0
22
- return true
23
- else
24
- return false
25
- end
8
+ return input % 2 == 0
26
9
  end
10
+
11
+
27
12
  def self.greatest(array)
28
- if not array.kind_of?(Array) then raise TypeError, "expected: Array" end
13
+ if not array.kind_of?(Array) then raise TypeError end
29
14
  greatest_index = 0
30
15
  for i in 0..array.length - 1
31
16
  if array[i] > array[greatest_index]
@@ -34,8 +19,10 @@ module Glib
34
19
  end
35
20
  return greatest_index
36
21
  end
22
+
23
+
37
24
  def self.smallest(array)
38
- if not array.kind_of?(Array) then raise TypeError, "expected: Array" end
25
+ if not array.kind_of?(Array) then raise TypeError end
39
26
  smallest_index = 0
40
27
  for i in 1..array.length - 1
41
28
  if array[i] < array[smallest_index]
@@ -44,12 +31,99 @@ module Glib
44
31
  end
45
32
  return smallest_index
46
33
  end
47
- def self.normalize(array, char)
48
- if not array.kind_of?(Array) then raise TypeError, "expected: Array" end
34
+
35
+
36
+ def self.normalize(array, char = ",")
37
+ if not array.kind_of?(Array) then raise TypeError end
49
38
  concat = ""
50
39
  for i in 0..array.length - 1
51
40
  concat = concat + array[i] + char
52
41
  end
53
42
  return concat[0..-2]
54
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
+ end
78
+
79
+ class Array
80
+ def tableprint()
81
+ long = 0
82
+ for i in 0..self.length - 1
83
+ for j in 0..self[i].length - 1
84
+ if self[i][j].to_s.length > long
85
+ long = self[i][j].to_s.length
86
+ end
87
+ end
88
+ end
89
+
90
+ for i in 0..self.length - 1
91
+ for j in 0..self[i].length - 1
92
+ spaces = " "
93
+ for k in 1..long - self[i][j].to_s.length
94
+ spaces = spaces + " "
95
+ end
96
+ print self[i][j].to_s + spaces
97
+ end
98
+ puts ""
99
+ end
100
+ end
101
+
102
+ def normalize(char = ",")
103
+ concat = ""
104
+ for i in 0..self.length - 1
105
+ concat = concat + self[i] + char
106
+ end
107
+ return concat[0..-2]
108
+ end
109
+
110
+ def smallest()
111
+ smallest_index = 0
112
+ for i in 1..self.length - 1
113
+ if self[i] < self[smallest_index]
114
+ smallest_index = i
115
+ end
116
+ end
117
+ return smallest_index
118
+ end
119
+
120
+ def greatest()
121
+ greatest_index = 0
122
+ for i in 0..self.length - 1
123
+ if self[i] > self[greatest_index]
124
+ greatest_index = i
125
+ end
126
+ end
127
+ return greatest_index
128
+ end
55
129
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Vian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-20 00:00:00.000000000 Z
11
+ date: 2018-04-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Testing gem
14
14
  email: casa@gabrielvian.it
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
37
  version: '0'
38
38
  requirements: []
39
39
  rubyforge_project:
40
- rubygems_version: 2.6.11
40
+ rubygems_version: 2.6.13
41
41
  signing_key:
42
42
  specification_version: 4
43
43
  summary: Completely useless