Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/glib-array.rb
Instance Method Summary collapse
Instance Method Details
#greatest ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/glib-array.rb', line 34 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 |
#smallest ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/glib-array.rb', line 24 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
44 45 46 47 48 49 50 |
# File 'lib/glib-array.rb', line 44 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 |