Class: AnnRps::Comp
- Inherits:
-
Object
- Object
- AnnRps::Comp
- Defined in:
- lib/ann_rps.rb
Instance Attribute Summary collapse
-
#choice ⇒ Object
readonly
Returns the value of attribute choice.
Instance Method Summary collapse
- #choose ⇒ Object
- #greeting(name) ⇒ Object
-
#initialize ⇒ Comp
constructor
A new instance of Comp.
Constructor Details
#initialize ⇒ Comp
Returns a new instance of Comp.
20 21 |
# File 'lib/ann_rps.rb', line 20 def initialize end |
Instance Attribute Details
#choice ⇒ Object (readonly)
Returns the value of attribute choice.
19 20 21 |
# File 'lib/ann_rps.rb', line 19 def choice @choice end |
Instance Method Details
#choose ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ann_rps.rb', line 27 def choose num_choice = rand(1..3) if num_choice ==1 puts "I chose Rock." @choice = "r" elsif num_choice ==2 puts "I chose Paper." @choice = "p" else puts "I chose Scissors." @choice = "s" end end |
#greeting(name) ⇒ Object
23 24 25 |
# File 'lib/ann_rps.rb', line 23 def greeting(name) puts "Hello #{name}, I'm Conrad. Let's play a game of Rock Paper Scissors. " end |