Class: Main

Inherits:
Object
  • Object
show all
Defined in:
lib/freshmind.rb

Constant Summary collapse

LEFT_UP_CORNER =
"\u250c"
RIGHT_UP_CORNER =
"\u2510"
LEFT_DOWN_CORNER =
"\u2514"
RIGHT_DOWN_CORNER =
"\u2518"
VERTICAL_BORDER =
"\u2502"
HORIZONTAL_BORDER =
"\u2500"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row_size, commands, alfabet) ⇒ Main

Returns a new instance of Main.



48
49
50
51
52
# File 'lib/freshmind.rb', line 48

def initialize(row_size, commands, alfabet)
  @row_size = row_size
  @commands = commands
  @alfabet = alfabet
end

Instance Attribute Details

#alfabetObject (readonly)

Returns the value of attribute alfabet.



40
41
42
# File 'lib/freshmind.rb', line 40

def alfabet
  @alfabet
end

#commandsObject (readonly)

Returns the value of attribute commands.



40
41
42
# File 'lib/freshmind.rb', line 40

def commands
  @commands
end

#row_sizeObject (readonly)

Returns the value of attribute row_size.



40
41
42
# File 'lib/freshmind.rb', line 40

def row_size
  @row_size
end

Instance Method Details

#outObject



60
61
62
63
64
65
66
# File 'lib/freshmind.rb', line 60

def out
  puts top_border
  result.each_slice(row_size) do |row|
    puts VERTICAL_BORDER + " " + row.join(" ") + " " + VERTICAL_BORDER
  end
  puts bottom_border
end

#resultObject



54
55
56
57
58
# File 'lib/freshmind.rb', line 54

def result
  alfabet.map do |l| 
    l + commands[rand(300)].red
  end
end