Class: Itest5ch::BoardListPage

Inherits:
Object
  • Object
show all
Includes:
HttpMethods
Defined in:
lib/itest5ch/board_list_page.rb

Constant Summary collapse

BOARDS_URL =
"http://itest.5ch.net/".freeze

Instance Method Summary collapse

Methods included from HttpMethods

#get_html, #get_json

Instance Method Details

#allHash<String, Array<Itest5ch::Board>>

Get all boards

Returns:

  • (Hash<String, Array<Itest5ch::Board>>)

    key: category name, value: boards



10
11
12
13
14
15
16
17
18
# File 'lib/itest5ch/board_list_page.rb', line 10

def all
  doc = Hpricot(get_html(BOARDS_URL))

  doc.search("//div[@id='bbsmenu']//ul[@class='pure-menu-list']").
    reject {|ul| ul["id"] == "history" }.each_with_object({}) do |ul, categories|
    category_name = ul.at("/li[@class='pure-menu-item pure-menu-selected']").inner_text.strip
    categories[category_name] = get_boards(ul)
  end
end