Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/glib-array.rb
Instance Method Summary collapse
- #greatest ⇒ Object
- #normalize(char = ",") ⇒ Object
- #smallest ⇒ Object
- #tableprint ⇒ Object
- #uniform ⇒ Object
Instance Method Details
#greatest ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/glib-array.rb', line 42 def greatest() greatest_index = 0 for i in 0..self.length - 1 if self[i] > self[greatest_index] greatest_index = i end end return greatest_index end |
#normalize(char = ",") ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/glib-array.rb', line 24 def normalize(char = ",") concat = "" for i in 0..self.length - 1 concat = concat + self[i] + char end return concat[0..-2] end |
#smallest ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/glib-array.rb', line 32 def smallest() smallest_index = 0 for i in 1..self.length - 1 if self[i] < self[smallest_index] smallest_index = i end end return smallest_index end |
#tableprint ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/glib-array.rb', line 2 def tableprint() long = 0 for i in 0..self.length - 1 for j in 0..self[i].length - 1 if self[i][j].to_s.length > long long = self[i][j].to_s.length end end end for i in 0..self.length - 1 for j in 0..self[i].length - 1 spaces = " " for k in 1..long - self[i][j].to_s.length spaces = spaces + " " end print self[i][j].to_s + spaces end puts "" end end |
#uniform ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/glib-array.rb', line 52 def uniform() tot = self.length - 1 for i in 1..self.length - 1 if self[i] == self[0] then tot-=1 end end return tot == 0 end |