Class: Rubygoal::MatchData
- Inherits:
-
Object
- Object
- Rubygoal::MatchData
- Defined in:
- lib/rubygoal/match_data.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#ball ⇒ Object
readonly
Returns the value of attribute ball.
-
#me ⇒ Object
readonly
Returns the value of attribute me.
-
#other ⇒ Object
readonly
Returns the value of attribute other.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(my_score, other_score, ball_position, my_positions, other_positions, time) ⇒ MatchData
constructor
A new instance of MatchData.
- #result(my_score, other_score) ⇒ Object
Constructor Details
#initialize(my_score, other_score, ball_position, my_positions, other_positions, time) ⇒ MatchData
Returns a new instance of MatchData.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/rubygoal/match_data.rb', line 105 def initialize(my_score, other_score, ball_position, my_positions, other_positions, time) @me = MatchData::Team.new( my_score, result(my_score, other_score), my_positions ) @other = MatchData::Team.new( other_score, result(other_score, my_score), other_positions ) @time = time @ball = ball_position end |
Instance Attribute Details
#ball ⇒ Object (readonly)
Returns the value of attribute ball.
103 104 105 |
# File 'lib/rubygoal/match_data.rb', line 103 def ball @ball end |
#me ⇒ Object (readonly)
Returns the value of attribute me.
103 104 105 |
# File 'lib/rubygoal/match_data.rb', line 103 def me @me end |
#other ⇒ Object (readonly)
Returns the value of attribute other.
103 104 105 |
# File 'lib/rubygoal/match_data.rb', line 103 def other @other end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
103 104 105 |
# File 'lib/rubygoal/match_data.rb', line 103 def time @time end |
Instance Method Details
#result(my_score, other_score) ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'lib/rubygoal/match_data.rb', line 120 def result(my_score, other_score) if my_score > other_score :win elsif my_score < other_score :lose else :draw end end |