Class: Message
- Inherits:
-
Object
- Object
- Message
- Defined in:
- lib/game_codebreaker/message.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#history ⇒ Object
Returns the value of attribute history.
-
#number ⇒ Object
Returns the value of attribute number.
-
#turns ⇒ Object
Returns the value of attribute turns.
-
#user ⇒ Object
Returns the value of attribute user.
-
#win ⇒ Object
Returns the value of attribute win.
Instance Method Summary collapse
Instance Attribute Details
#history ⇒ Object
Returns the value of attribute history.
3 4 5 |
# File 'lib/game_codebreaker/message.rb', line 3 def history @history end |
#number ⇒ Object
Returns the value of attribute number.
3 4 5 |
# File 'lib/game_codebreaker/message.rb', line 3 def number @number end |
#turns ⇒ Object
Returns the value of attribute turns.
3 4 5 |
# File 'lib/game_codebreaker/message.rb', line 3 def turns @turns end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/game_codebreaker/message.rb', line 3 def user @user end |
#win ⇒ Object
Returns the value of attribute win.
3 4 5 |
# File 'lib/game_codebreaker/message.rb', line 3 def win @win end |
Instance Method Details
#mess(value) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/game_codebreaker/message.rb', line 30 def mess( value ) case value when 1 %Q^ Enter your integer and press 'Enter' ^ when 2 %Q^ Replay ? -- Y/N ^ when 4 %Q^ Save games? -- Y/N ^ when 5 %Q^ I am waiting the GARBAGE COLLECTOR ^ when 6 %Q^ Please enter your data separated by a space and press 'Enter'. Example: Name Surname Age ^ else %Q^ читер ? ^ end end |
#print_info(array) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/game_codebreaker/message.rb', line 19 def print_info( array ) p "Name: " << array[0] p "Surname: " << array[1] p "Age " << array[2] p "Total games " << array[3].to_s p "Total wins " << array[4].to_s p "Total losses " << array[5].to_s p "Average amount of turns " << array[6].to_s p "Average amount of level " << array[7].to_s end |
#question(mess) ⇒ Object
5 6 7 8 |
# File 'lib/game_codebreaker/message.rb', line 5 def question( mess ) p mess value = gets.chomp end |
#user_data ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/game_codebreaker/message.rb', line 10 def user_data if question( mess 4 ).capitalize == "Y" user = question( mess 6 ) user_data unless user =~ /^(.+)\s(.+)\s(.+)$/ return array = [name = $1, surname = $2, age = $3] end false end |