Class: Pokerstats::HandHistory
- Inherits:
-
Object
- Object
- Pokerstats::HandHistory
- Defined in:
- lib/pokerstats/hand_history.rb
Instance Attribute Summary collapse
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#position ⇒ Object
Returns the value of attribute position.
-
#source ⇒ Object
Returns the value of attribute source.
-
#stats ⇒ Object
Returns the value of attribute stats.
Instance Method Summary collapse
- #game ⇒ Object
-
#initialize(lines, source, position, parser_class = PokerstarsHandHistoryParser) ⇒ HandHistory
constructor
A new instance of HandHistory.
- #parse ⇒ Object
- #parsed? ⇒ Boolean
- #reports ⇒ Object
Constructor Details
#initialize(lines, source, position, parser_class = PokerstarsHandHistoryParser) ⇒ HandHistory
Returns a new instance of HandHistory.
8 9 10 11 12 13 14 15 |
# File 'lib/pokerstats/hand_history.rb', line 8 def initialize lines, source, position, parser_class = PokerstarsHandHistoryParser @lines = lines @source = source @position = position @parsed = false @parser_class = parser_class @stats = HandStatistics.new end |
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
6 7 8 |
# File 'lib/pokerstats/hand_history.rb', line 6 def lines @lines end |
#position ⇒ Object
Returns the value of attribute position.
6 7 8 |
# File 'lib/pokerstats/hand_history.rb', line 6 def position @position end |
#source ⇒ Object
Returns the value of attribute source.
6 7 8 |
# File 'lib/pokerstats/hand_history.rb', line 6 def source @source end |
#stats ⇒ Object
Returns the value of attribute stats.
6 7 8 |
# File 'lib/pokerstats/hand_history.rb', line 6 def stats @stats end |
Instance Method Details
#game ⇒ Object
17 18 19 20 |
# File 'lib/pokerstats/hand_history.rb', line 17 def game return nil if lines.empty? @parser_class.game lines.first end |
#parse ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pokerstats/hand_history.rb', line 26 def parse @parser = @parser_class.new(@stats) @lines.each do |each_line| begin @parser.parse(each_line) rescue => e raise HandHistoryParseError, "#{@source}:#{position}: #{e.}" end end @stats.update_hand :session_filename => source, :starting_at => position @parsed = true end |
#parsed? ⇒ Boolean
22 23 24 |
# File 'lib/pokerstats/hand_history.rb', line 22 def parsed? @parsed end |
#reports ⇒ Object
39 40 41 42 |
# File 'lib/pokerstats/hand_history.rb', line 39 def reports parse unless parsed? @stats.reports end |