Class: Pokerstats::PokerEdge

Inherits:
Object
  • Object
show all
Defined in:
lib/pokerstats/poker-edge.rb

Instance Method Summary collapse

Constructor Details

#initialize(screen_name) ⇒ PokerEdge

Returns a new instance of PokerEdge.



8
9
10
# File 'lib/pokerstats/poker-edge.rb', line 8

def initialize screen_name
  @screen_name = URI.escape(screen_name)
end

Instance Method Details

#get_response_from_internetObject



12
13
14
15
16
17
18
19
# File 'lib/pokerstats/poker-edge.rb', line 12

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

#player_typeObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pokerstats/poker-edge.rb', line 37

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

#preflop_styleObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pokerstats/poker-edge.rb', line 25

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

#report(format = "%20s -- %s -- %s\n") ⇒ Object



49
50
51
52
53
54
55
# File 'lib/pokerstats/poker-edge.rb', line 49

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

#responseObject



21
22
23
# File 'lib/pokerstats/poker-edge.rb', line 21

def response
  @response ||= get_response_from_internet
end