Class: Conquest::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/conquest/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Parser

Returns a new instance of Parser.



9
10
11
12
13
14
15
# File 'lib/conquest/parser.rb', line 9

def initialize(url)
  # Grab all of the rows from the table containing all of the Pokemon.
  # Drop the first two because they just have header data.
  @pkmn = Nokogiri::HTML(open(url)).css("table.tab > tr").drop(1).map do |p|
    PkmnInfo.new p.children[0].text[1..-1].to_i, p.children[4].text
  end
end

Instance Method Details

#ards_codeObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/conquest/parser.rb', line 23

def ards_code
  @pkmn.each_with_index.map do |p, i|
    <<-EOS.heredoc % i
      ::#{p.name}
      52045804 E2431001
      02045808 E3A060%.2X
      D2000000 00000000
    EOS
  end.join "\n"
end

#hex_listObject



17
18
19
20
21
# File 'lib/conquest/parser.rb', line 17

def hex_list
  @pkmn.each_with_index.
    map { |p, i| "%03d - %.2X - %s" % [p.id, i, p.name] }.
    join "\n"
end