Sha256: 4dc46c2e67831b274c70592720840b9d033714f3efb38ebea8925f156d27e9dc

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/hand_constants")
require File.expand_path(File.dirname(__FILE__) + "/pokerstars_hand_history_parser")

module Pokerstats
  class HandHistory
    attr_accessor :lines, :source, :position, :stats
    
    def initialize lines, source, position, parser_class = PokerstarsHandHistoryParser
      @lines = lines
      @source = source
      @position = position
      @parsed = false
      @parser_class = parser_class
      @stats = HandStatistics.new
    end
    
    def game
      @parser_class.game lines.first
    end
  
    def parsed?
      @parsed
    end
  
    def parse
      @parser = @parser_class.new(@stats)
      @lines.each do |each_line| 
        begin
          @parser.parse(each_line)
        rescue => e
          raise "#{@source}:#{position}: #{e.message}"
        end
      end
      @stats.update_hand :session_filename => source, :starting_at => position
      @parsed = true
    end
  
    def reports
      parse unless parsed?
      @stats.reports
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pokerstats-2.0.14 lib/pokerstats/hand_history.rb
pokerstats-2.0.13 lib/pokerstats/hand_history.rb
pokerstats-2.0.12 lib/pokerstats/hand_history.rb
pokerstats-2.0.11 lib/pokerstats/hand_history.rb
pokerstats-2.0.6 lib/pokerstats/hand_history.rb