Class: Tarot::Fortune
- Inherits:
-
Object
- Object
- Tarot::Fortune
- Defined in:
- lib/marxbot/tarot/fortune.rb
Instance Attribute Summary collapse
-
#deck ⇒ Object
readonly
Returns the value of attribute deck.
-
#hand ⇒ Object
readonly
Returns the value of attribute hand.
-
#hand_size ⇒ Object
readonly
Returns the value of attribute hand_size.
Instance Method Summary collapse
- #draw_hand ⇒ Object
- #fortune_structures ⇒ Object
-
#initialize ⇒ Fortune
constructor
A new instance of Fortune.
- #link_word ⇒ Object
- #maybe_word ⇒ Object
- #tell_fortune ⇒ Object
Constructor Details
Instance Attribute Details
#deck ⇒ Object (readonly)
Returns the value of attribute deck.
6 7 8 |
# File 'lib/marxbot/tarot/fortune.rb', line 6 def deck @deck end |
#hand ⇒ Object (readonly)
Returns the value of attribute hand.
6 7 8 |
# File 'lib/marxbot/tarot/fortune.rb', line 6 def hand @hand end |
#hand_size ⇒ Object (readonly)
Returns the value of attribute hand_size.
6 7 8 |
# File 'lib/marxbot/tarot/fortune.rb', line 6 def hand_size @hand_size end |
Instance Method Details
#draw_hand ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/marxbot/tarot/fortune.rb', line 13 def draw_hand() cards = [] hand_size.times do |i| flipped = [true,false].sample card_data = deck.sample deck.reject!{|c| c == card_data} # binding.pry cards << Card.new(card_data, flipped) end return cards end |
#fortune_structures ⇒ Object
34 35 36 37 38 |
# File 'lib/marxbot/tarot/fortune.rb', line 34 def fortune_structures() lines = [ "#{hand[0].adjective} #{hand[1].noun} #{maybe_word} #{hand[2].verb} #{link_word} #{hand[3].noun}" ] end |
#link_word ⇒ Object
40 41 42 |
# File 'lib/marxbot/tarot/fortune.rb', line 40 def link_word ["for", "because of", "thanks to", "and so", "thus, the"].sample end |
#maybe_word ⇒ Object
44 45 46 |
# File 'lib/marxbot/tarot/fortune.rb', line 44 def maybe_word ["will", "could", "shall", "ought to", "should"].sample end |
#tell_fortune ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/marxbot/tarot/fortune.rb', line 26 def tell_fortune() puts hand.map{|card| "#{card.flipped} #{card.name}"} return { cards: hand, result: fortune_structures.sample } end |