Class: Ruby2ch::Thre
- Inherits:
-
Object
- Object
- Ruby2ch::Thre
- Defined in:
- lib/ruby2ch/thre.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#ids ⇒ Object
Returns the value of attribute ids.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #impetus ⇒ Object
-
#initialize(url) ⇒ Thre
constructor
A new instance of Thre.
Constructor Details
#initialize(url) ⇒ Thre
Returns a new instance of Thre.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby2ch/thre.rb', line 6 def initialize(url) @agent = Mechanize.new @page = @agent.get(url) @title = (@page/"h1").text @res = (@page/"dd").map{|r| r.text} @name = (@page/"dt").map{|n| n.text} @name.map!{|nn| nn.split(":")} @no = @name.map{|n| n[0]} @hn = @name.map{|n| n[1]} name_split = @name.map{|n| n[2].split(" ")} @ids = name_split.map{|n| n[2]}.uniq.map{|id| puts id id.sub("ID:","")} @date1 = name_split.map{|n| n[0]}.map{|n| n.sub(/\(.\)/,"")} @time = name_split.map{|n| n[1]} @date = @date1[0] + " " + @time[0] end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
28 29 30 |
# File 'lib/ruby2ch/thre.rb', line 28 def date @date end |
#ids ⇒ Object
Returns the value of attribute ids.
28 29 30 |
# File 'lib/ruby2ch/thre.rb', line 28 def ids @ids end |
#title ⇒ Object
Returns the value of attribute title.
28 29 30 |
# File 'lib/ruby2ch/thre.rb', line 28 def title @title end |
Instance Method Details
#impetus ⇒ Object
24 25 26 |
# File 'lib/ruby2ch/thre.rb', line 24 def impetus return @res.size/(Time.now - Time.parse(@date)) * 60 * 60 * 24 end |