class Itest5ch::Board
Attributes
name[RW]
@!attribute [rw] name
@return [String]
url[RW]
@!attribute [rw] url
@return [String]
Public Class Methods
all()
click to toggle source
Get all boards
@return [Hash<String, Array<Itest5ch::Board>>] key: category name, value: boards
# File lib/itest5ch/board.rb, line 57 def self.all BoardListPage.new.all end
find(board_name)
click to toggle source
@param board_name [String] name or id
@return [Itest5ch::Board]
# File lib/itest5ch/board.rb, line 71 def self.find(board_name) url = "#{Itest5ch::BoardListPage::BOARDS_URL}subback/#{board_name}" all.values.flatten.find {|board| board_name == board.name || url == board.url } end
find_category_boards(category_name)
click to toggle source
@param category_name [String]
@return [Array<Itest5ch::Board>]
# File lib/itest5ch/board.rb, line 64 def self.find_category_boards(category_name) all[category_name] end
new(url, name: nil)
click to toggle source
@param url [String] @param name [String]
# File lib/itest5ch/board.rb, line 15 def initialize(url, name: nil) @url = url @name = name end
Public Instance Methods
==(other)
click to toggle source
@param other [Itest5ch::Board]
@return [Boolean]
# File lib/itest5ch/board.rb, line 23 def ==(other) other.is_a?(Board) && url == other.url && name == other.name end
json_url()
click to toggle source
@return [String]
# File lib/itest5ch/board.rb, line 42 def json_url if (m = url.match(%r{^https?://itest\.5ch\.net/subback/(.+?)/?$})) return "http://itest.5ch.net/subbacks/#{m[1]}.json" end if (m = url.match(%r{^https?://.+\.5ch\.net/(.+?)/?$})) return "http://itest.5ch.net/subbacks/#{m[1]}.json" end raise "Unknown url: #{url}" end
threads()
click to toggle source
@return [Array<Itest5ch::Thread>]
# File lib/itest5ch/board.rb, line 28 def threads hash = get_json(json_url, referer: url) hash["threads"].map do |thread| board, dat = thread[3].split("/", 2) Itest5ch::Thread.new( subdomain: thread[2], board: board, dat: dat.to_i, name: thread[5], ) end end