class BBS2ch::Board
Attributes
name[RW]
url[RW]
Public Class Methods
new(name, url)
click to toggle source
# File lib/bbs2ch/board.rb, line 3 def initialize(name, url) @name = name @url = url @threads = nil end
Public Instance Methods
load_threads()
click to toggle source
# File lib/bbs2ch/board.rb, line 18 def load_threads body = Connection.new(url + '/subject.txt').response_body body.each_line.map { |line| line.chomp! title_end = line.rindex(' ') dat, title = line[0...title_end].split('<>') res_count = line[title_end + 1 .. -1][/[0-9]+/].to_i BBS2ch::Thread.new(title, "#{url}/dat/#{dat}", res_count) } end
threads(regex = nil)
click to toggle source
# File lib/bbs2ch/board.rb, line 11 def threads(regex = nil) @threads ||= load_threads return @threads unless regex @threads.select { |thread| thread.name.match(regex) } end