Class: Ruby2ch::Board

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Board

Returns a new instance of Board.



9
10
11
12
13
14
15
# File 'lib/ruby2ch/board.rb', line 9

def initialize(url)
  @agent = Mechanize.new
  @page = @agent.get(url)
  @links = @page.links.map{|link| link.href}.map{|link| link.split("/")[0]}
  @links.map!{|link| url.sub("/news/subback.html","/test/read.cgi/news/") + link}
  @links.select!{|x| /\/\d*$/ =~x}
end

Instance Attribute Details

Returns the value of attribute links.



31
32
33
# File 'lib/ruby2ch/board.rb', line 31

def links
  @links
end

Instance Method Details

#threadsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby2ch/board.rb', line 17

def threads
  threads = []
  @links.each{|link|
    threads << Thread.start(link){|link| Dat.new(link)}
  }

  threads.map!{|thre|
    thre.join.value
  }

  return threads

end