Class: Phi::Losophy::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/phi/losophy/page.rb,
lib/phi/losophy/page/node.rb

Defined Under Namespace

Classes: Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(term, connection) ⇒ Page

Returns a new instance of Page.



7
8
9
10
# File 'lib/phi/losophy/page.rb', line 7

def initialize(term, connection)
  @term       = term
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/phi/losophy/page.rb', line 5

def connection
  @connection
end

#termObject (readonly)

Returns the value of attribute term.



5
6
7
# File 'lib/phi/losophy/page.rb', line 5

def term
  @term
end

Instance Method Details

#inspectObject



20
21
22
# File 'lib/phi/losophy/page.rb', line 20

def inspect
  "#<#{self.class.name}:#{term}>"
end

#nextObject



16
17
18
# File 'lib/phi/losophy/page.rb', line 16

def next
  @next ||= Page.new(next_term, connection)
end

#next_termObject



24
25
26
# File 'lib/phi/losophy/page.rb', line 24

def next_term
  Node.new(html.css(selector)).anchor.attr("href")[6..-1]
end

#philosophy?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/phi/losophy/page.rb', line 12

def philosophy?
  term.downcase == "philosophy"
end