class Mona::Board

Board of 2ch.net

Attributes

board[R]
host[R]

Public Class Methods

new(host, board) click to toggle source

initialize method

host

subdomain

board

board name

example

if you want to access hayabusa2.2ch.net/news4vip/

Mona::Board.new('hayabusa2', 'news4vip')
# File lib/mona/board.rb, line 18
def initialize(host, board)
  @host = host
  @board = board
end

Public Instance Methods

threads() click to toggle source

get threads

array of Thread

# File lib/mona/board.rb, line 28
def threads
  @threads ||= connect.toutf8.lines.map do |line|
    _, id, title, res_num = line.split(/^(\d+)\.dat<>(.+)\((\d+\))$/)
    Mona::Thread.new(board: self, title: title.strip, res_num: res_num.to_i, id: id.to_i)
  end
end

Private Instance Methods

connect() click to toggle source
# File lib/mona/board.rb, line 44
def connect
  res = Mona::Client.new.get(dat_url)
  if res.status == 200
    res.content.toutf8
  end
end
dat_url() click to toggle source

url for subject.txt

# File lib/mona/board.rb, line 40
def dat_url
  "http://#{@host}/#{@board}/subject.txt"
end