Class: GREE::Community
- Inherits:
-
Object
- Object
- GREE::Community
- Defined in:
- lib/gree-community.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#recent_threads ⇒ Object
readonly
Returns the value of attribute recent_threads.
Instance Method Summary collapse
- #fetch(fetcher) ⇒ Object
-
#initialize(id) ⇒ Community
constructor
A new instance of Community.
- #recent_threads_uri ⇒ Object
Constructor Details
#initialize(id) ⇒ Community
Returns a new instance of Community.
8 9 10 |
# File 'lib/gree-community.rb', line 8 def initialize id @id=id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/gree-community.rb', line 11 def id @id end |
#recent_threads ⇒ Object (readonly)
Returns the value of attribute recent_threads.
12 13 14 |
# File 'lib/gree-community.rb', line 12 def recent_threads @recent_threads end |
Instance Method Details
#fetch(fetcher) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gree-community.rb', line 18 def fetch(fetcher) page=fetcher.get(recent_threads_uri) @recent_threads=page.search('.feed .item').map{|item| thread_uri = item.at('.head a').attr(:href) thread_uri =~ /&thread_id=(\d+)/ thread_id = Integer($1) thread_title = item.at('.head a strong').text Thread.new( thread_id, title: thread_title, ) } end |
#recent_threads_uri ⇒ Object
13 14 15 16 17 |
# File 'lib/gree-community.rb', line 13 def recent_threads_uri URI.parse( "http://gree.jp/?mode=community&act=bbs_list&community_id=#{id}" ) end |