Top Level Namespace

Includes:
ConsoleExtensions

Defined Under Namespace

Modules: ConsoleExtensions, Fertilizer Classes: AriGenerator, Object

Instance Method Summary collapse

Methods included from ConsoleExtensions

#cls, #code, #reload_lib

Instance Method Details

#col_widthObject



3
# File 'lib/fertilizer/object_extensions.rb', line 3

def col_width; 25; end

#colputs(array) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fertilizer/object_extensions.rb', line 1

def colputs(array)
  def num_columns; 4; end
  def col_width; 25; end
  def force_length(x)
    x = x.to_s
    max_length = col_width+2
    if x.length > max_length
      x = x[0..max_length-4] + '...'
    end
    x += (' '*max_length)
    x[0..max_length-1]
  end
  def get_element(array, i) # displays in column order instead of row order
    num_rows = (array.length/num_columns)+1
    col = i % num_columns
    row = i / num_columns
    array[col*num_rows+row]
  end
  for i in (0..array.length)
    print force_length(get_element(array, i))
    print "  "
    puts if (i % num_columns) == (num_columns-1)
  end
  nil
end

#force_length(x) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/fertilizer/object_extensions.rb', line 4

def force_length(x)
  x = x.to_s
  max_length = col_width+2
  if x.length > max_length
    x = x[0..max_length-4] + '...'
  end
  x += (' '*max_length)
  x[0..max_length-1]
end

#get_element(array, i) ⇒ Object

displays in column order instead of row order



13
14
15
16
17
18
# File 'lib/fertilizer/object_extensions.rb', line 13

def get_element(array, i) # displays in column order instead of row order
  num_rows = (array.length/num_columns)+1
  col = i % num_columns
  row = i / num_columns
  array[col*num_rows+row]
end

#num_columnsObject



2
# File 'lib/fertilizer/object_extensions.rb', line 2

def num_columns; 4; end