Class: Rbcalc::Engine
- Inherits:
-
Object
- Object
- Rbcalc::Engine
- Defined in:
- lib/rbcalc/engine.rb
Instance Attribute Summary collapse
-
#hands ⇒ Object
Returns the value of attribute hands.
-
#leader ⇒ Object
Returns the value of attribute leader.
-
#played ⇒ Object
Returns the value of attribute played.
-
#tricks_made ⇒ Object
Returns the value of attribute tricks_made.
-
#trump_suit ⇒ Object
Returns the value of attribute trump_suit.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Engine
constructor
A new instance of Engine.
- #parse! ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Engine
Returns a new instance of Engine.
15 16 17 |
# File 'lib/rbcalc/engine.rb', line 15 def initialize params = {} params.map { |k,v| self.send(:"#{k}=",v) } end |
Instance Attribute Details
#hands ⇒ Object
Returns the value of attribute hands.
13 14 15 |
# File 'lib/rbcalc/engine.rb', line 13 def hands @hands end |
#leader ⇒ Object
Returns the value of attribute leader.
13 14 15 |
# File 'lib/rbcalc/engine.rb', line 13 def leader @leader end |
#played ⇒ Object
Returns the value of attribute played.
13 14 15 |
# File 'lib/rbcalc/engine.rb', line 13 def played @played end |
#tricks_made ⇒ Object
Returns the value of attribute tricks_made.
13 14 15 |
# File 'lib/rbcalc/engine.rb', line 13 def tricks_made @tricks_made end |
#trump_suit ⇒ Object
Returns the value of attribute trump_suit.
13 14 15 |
# File 'lib/rbcalc/engine.rb', line 13 def trump_suit @trump_suit end |
Instance Method Details
#parse! ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rbcalc/engine.rb', line 19 def parse! if hands.nil? || hands.empty? || leader.nil? || trump_suit.nil? raise ArgumentError, 'Rbcalc needs at least the hands, dealer direction and trump suit' end self.tricks_made = solve(hands, "#{played.to_s} e", trump_suit, leader) end |