Class: Ruby2ch::Board
- Inherits:
-
Object
- Object
- Ruby2ch::Board
- Defined in:
- lib/ruby2ch/board.rb
Instance Attribute Summary collapse
-
#links ⇒ Object
Returns the value of attribute links.
Instance Method Summary collapse
-
#initialize(url) ⇒ Board
constructor
A new instance of Board.
- #threads ⇒ Object
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
#links ⇒ Object
Returns the value of attribute links.
31 32 33 |
# File 'lib/ruby2ch/board.rb', line 31 def links @links end |
Instance Method Details
#threads ⇒ Object
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 |