Sha256: eb40e35fb0316f5329269c644988ba965a2f022fcfdd70f1d8cc2402ede403e3

Contents?: true

Size: 1.22 KB

Versions: 25

Compression:

Stored size: 1.22 KB

Contents

require 'rubygems'
require 'hpricot'
require 'open-uri'

module Pokerstats
  class PokerEdge
  
    def initialize screen_name
      @screen_name = URI.escape(screen_name)
    end
  
    def get_response_from_internet
      url = "http://www.poker-edge.com/whoami.php?name=#{@screen_name}"
      puts url
      open(url) do |f|
        @response = f.read
      end
      @response
    end
  
    def response
      @response ||= get_response_from_internet
    end
  
    def preflop_style
      if self.response =~ /(Pre-Flop Tend.*\n)/
        verbose = $1.gsub(/<\/?[^>]*>/, "")
        if verbose =~ /Pre-Flop Tendency: ([^-]*) -/
          preflop_style = $1
        else
          preflop_style = "N/A"
        end
      end
      preflop_style
    end
  
    def player_type
      if response =~ /(Player Type.*\n)/
        verbose = $1.gsub(/<\/?[^>]*>/, "")
        if verbose =~ /[Yy]ou are a ([^(]* \(.*\))/
          player = $1
        else
          player = ""
        end
      end
      player
    end
  
    def report format = "%20s -- %s -- %s\n"
      open("foo.html", "w+") do |file|
        file.write(response)
      end
      `open foo.html`
      printf(format, @screen_name, preflop_style, player_type)
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
wizardwerdna-pokerstats-1.0.15 lib/pokerstats/poker-edge.rb
wizardwerdna-pokerstats-1.0.16 lib/pokerstats/poker-edge.rb
wizardwerdna-pokerstats-1.0.17 lib/pokerstats/poker-edge.rb
wizardwerdna-pokerstats-1.0.18 lib/pokerstats/poker-edge.rb
wizardwerdna-pokerstats-1.0.19 lib/pokerstats/poker-edge.rb
wizardwerdna-pokerstats-1.0.22 lib/pokerstats/poker-edge.rb
wizardwerdna-pokerstats-2.0.0 lib/pokerstats/poker-edge.rb
pokerstats-2.0.19 lib/pokerstats/poker-edge.rb
pokerstats-2.0.18 lib/pokerstats/poker-edge.rb
pokerstats-2.0.17 lib/pokerstats/poker-edge.rb
pokerstats-2.0.16 lib/pokerstats/poker-edge.rb
pokerstats-2.0.14 lib/pokerstats/poker-edge.rb
pokerstats-2.0.13 lib/pokerstats/poker-edge.rb
pokerstats-2.0.12 lib/pokerstats/poker-edge.rb
pokerstats-2.0.11 lib/pokerstats/poker-edge.rb
pokerstats-2.0.10 lib/pokerstats/poker-edge.rb
pokerstats-2.0.9 lib/pokerstats/poker-edge.rb
pokerstats-2.0.8 lib/pokerstats/poker-edge.rb
pokerstats-2.0.7 lib/pokerstats/poker-edge.rb
pokerstats-2.0.6 lib/pokerstats/poker-edge.rb