Class: Main
- Inherits:
-
Object
- Object
- Main
- 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
-
#alfabet ⇒ Object
readonly
Returns the value of attribute alfabet.
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#row_size ⇒ Object
readonly
Returns the value of attribute row_size.
Instance Method Summary collapse
-
#initialize(row_size, commands, alfabet) ⇒ Main
constructor
A new instance of Main.
- #out ⇒ Object
- #result ⇒ Object
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
#alfabet ⇒ Object (readonly)
Returns the value of attribute alfabet.
40 41 42 |
# File 'lib/freshmind.rb', line 40 def alfabet @alfabet end |
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
40 41 42 |
# File 'lib/freshmind.rb', line 40 def commands @commands end |
#row_size ⇒ Object (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
#out ⇒ Object
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 |
#result ⇒ Object
54 55 56 57 58 |
# File 'lib/freshmind.rb', line 54 def result alfabet.map do |l| l + commands[rand(300)].red end end |