Class: Pic2ch::Pages::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/pic2ch/pages/index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p) ⇒ Index

Returns a new instance of Index.



6
7
8
9
# File 'lib/pic2ch/pages/index.rb', line 6

def initialize(p)
  @p = p.to_i
  @p = 1 if @p < 1
end

Instance Attribute Details

#pObject (readonly)

Returns the value of attribute p.



4
5
6
# File 'lib/pic2ch/pages/index.rb', line 4

def p
  @p
end

Instance Method Details

#htmlObject

Fetch



25
26
27
# File 'lib/pic2ch/pages/index.rb', line 25

def html
  @html ||= open(url).read{}
end

#parserObject

Parsers



31
32
33
# File 'lib/pic2ch/pages/index.rb', line 31

def parser
  @parser ||= Parsers::Index.new(html)
end

#pathObject



18
19
20
# File 'lib/pic2ch/pages/index.rb', line 18

def path
  p == 1 ? '' : "/?p=#{p}"
end

#urlObject

Accessors



14
15
16
# File 'lib/pic2ch/pages/index.rb', line 14

def url
  Pic2ch.url + path
end