Class: Pic2ch::Parsers::Index
- Inherits:
-
Object
- Object
- Pic2ch::Parsers::Index
- Defined in:
- lib/pic2ch/parsers/index.rb
Defined Under Namespace
Modules: ElementParser
Instance Method Summary collapse
- #coded ⇒ Object
-
#construct(e) ⇒ Object
def get(code) Static.new(code) end.
- #doc ⇒ Object
- #elements ⇒ Object
-
#initialize(html) ⇒ Index
constructor
A new instance of Index.
- #pages ⇒ Object
- #threads ⇒ Object
Constructor Details
#initialize(html) ⇒ Index
Returns a new instance of Index.
15 16 17 |
# File 'lib/pic2ch/parsers/index.rb', line 15 def initialize(html) @html = html end |
Instance Method Details
#coded ⇒ Object
31 32 33 |
# File 'lib/pic2ch/parsers/index.rb', line 31 def coded @coded ||= all.inject({}){|hash,obj| hash[obj.code] = obj; hash} end |
#construct(e) ⇒ Object
def get(code)
Static.new(code)
end
43 44 45 46 47 48 49 50 |
# File 'lib/pic2ch/parsers/index.rb', line 43 def construct(e) [ e.text, # name e["href"], # link ElementParser.next_class_for(e, :created){|e| e.text}, # created ElementParser.next_class_for(e, :star ){|e| e.text}.to_i, # star ] end |
#doc ⇒ Object
19 20 21 |
# File 'lib/pic2ch/parsers/index.rb', line 19 def doc @doc ||= Nokogiri::HTML(@html) end |
#elements ⇒ Object
23 24 25 |
# File 'lib/pic2ch/parsers/index.rb', line 23 def elements @elements ||= doc.xpath("/html/body/div[2]/div[2]/a") end |