Class: WWW::TvTropes

Inherits:
Object
  • Object
show all
Defined in:
lib/www-tvtropes.rb,
lib/www-tvtropes/version.rb

Overview

:nodoc:

Constant Summary collapse

VERSION =
'0.0.2'

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ TvTropes

Returns a new instance of TvTropes.

Yields:

  • (_self)

Yield Parameters:

  • _self (WWW::TvTropes)

    the object that the method was called on



33
34
35
# File 'lib/www-tvtropes.rb', line 33

def initialize
  yield self if block_given?
end

Instance Method Details

#characters_as_deviceObject

Returns hash (name => url) of “Characters As Device” tropes from tvtropes.org/pmwiki/pmwiki.php/Main/CharactersAsDevice.



38
39
40
41
42
43
44
45
46
# File 'lib/www-tvtropes.rb', line 38

def characters_as_device
  tropes = {}
  doc = Nokogiri::HTML( open( 'http://tvtropes.org/pmwiki/pmwiki.php/Main/CharactersAsDevice'), nil, 'UTF-8' )
  # XXX doc = Nokogiri::HTML( open( './CharactersAsDevice'), nil, 'UTF-8' )
  doc.css('h2 + ul > li > a').each do |link|
    tropes[ link.content ] = link['href'] 
  end
  return tropes
end