Class: Crags::Category
- Inherits:
-
Object
- Object
- Crags::Category
- Extended by:
- Fetcher
- Defined in:
- lib/crags/category.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, abbr) ⇒ Category
constructor
A new instance of Category.
Methods included from Fetcher
fetch_doc, fetch_request, fetch_xml
Constructor Details
#initialize(name, abbr) ⇒ Category
Returns a new instance of Category.
6 7 8 9 |
# File 'lib/crags/category.rb', line 6 def initialize(name, abbr) @name = name @url = "/#{abbr}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/crags/category.rb', line 4 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/crags/category.rb', line 4 def url @url end |
Class Method Details
.all ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/crags/category.rb', line 21 def self.all links.collect do |link| url = link["href"] name = link.inner_html Category.new(name, url) end end |
.doc ⇒ Object
11 12 13 |
# File 'lib/crags/category.rb', line 11 def self.doc fetch_doc(Config.category_url) end |
.links ⇒ Object
15 16 17 18 19 |
# File 'lib/crags/category.rb', line 15 def self.links doc.search("div.col a").select do |link| (link["href"] =~ /forum/).nil? end end |