Class: Mona::Board

Inherits:
Object
  • Object
show all
Defined in:
lib/mona/board.rb

Overview

Board of 2ch.net

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, board) ⇒ Board

initialize method

host

subdomain

board

board name

example

if you want to access hayabusa2.2ch.net/news4vip/ Mona::Board.new(‘hayabusa2’, ‘news4vip’)



18
19
20
21
# File 'lib/mona/board.rb', line 18

def initialize(host, board)
  @host = host
  @board = board
end

Instance Attribute Details

#boardObject (readonly)

Returns the value of attribute board.



7
8
9
# File 'lib/mona/board.rb', line 7

def board
  @board
end

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/mona/board.rb', line 7

def host
  @host
end

Instance Method Details

#threadsObject

get threads

array of Thread



28
29
30
31
32
33
# 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