Class: Mixi::Community
- Inherits:
-
Object
- Object
- Mixi::Community
- Defined in:
- lib/mixi-community.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch(fetcher) ⇒ Object
-
#initialize(id) ⇒ Community
constructor
A new instance of Community.
- #recent_bbses ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(id) ⇒ Community
Returns a new instance of Community.
12 13 14 |
# File 'lib/mixi-community.rb', line 12 def initialize(id) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/mixi-community.rb', line 16 def id @id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
17 18 19 |
# File 'lib/mixi-community.rb', line 17 def title @title end |
Class Method Details
.read_href(elm) ⇒ Object
6 7 8 9 10 |
# File 'lib/mixi-community.rb', line 6 def self.read_href(elm) URI.parse( elm.attr('data-url') || elm.attr(:href) ) end |
Instance Method Details
#fetch(fetcher) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mixi-community.rb', line 23 def fetch(fetcher) page = fetcher.get(uri) @recent_bbses = page.search('#newCommunityTopic .contents dl dd a').map {|a| bbs_uri = Mixi::Community.read_href(a) bbs_title = a.text bbs_id = Hash[bbs_uri.query.split('&').map{|kv|kv.split('=')}]['id'] BBS.new(self.id, bbs_id, title: bbs_title) } end |
#recent_bbses ⇒ Object
34 35 36 |
# File 'lib/mixi-community.rb', line 34 def recent_bbses @recent_bbses end |
#uri ⇒ Object
19 20 21 |
# File 'lib/mixi-community.rb', line 19 def uri URI.parse("http://mixi.jp/view_community.pl?id=#{id}") end |