Class: PinoyFilter::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/PinoyFilter.rb

Overview

This class serves as the binding class that holds all the central functions of the gem there should be no reason for anyone to interact with the other classes directly, without them being spawned by this class.

Instance Method Summary collapse

Constructor Details

#initialize(url = "http://www.theanime.tv/") ⇒ Site

call-seq:

initialize(void) => void
initialize(string) => void

The function will declare the domain used in the rest of the functions Should PinoyAnime go down or change name, etc. Hopefully this software will still work if you pass it the new address. must start with be http://, can not start with https://

Raises:

  • (ArgumentError)

22
23
24
25
26
# File 'lib/PinoyFilter.rb', line 22

def initialize(url="http://www.theanime.tv/")
  raise ArgumentError if url == nil
  raise PinoyFilter::URLException.new("URL is not valid") unless (url =~ /\A#{URI::regexp}\z/)
  @url = url[-1] == "/" ? url : "#{url}/"
end

Instance Method Details

#animesObject

call-seq:

animes => Pinoy::Anime[]

Workings

This function calls www.pinoyanime.tv/anime-lists/ and parses its HTML to get a list of all animation series currently listed on their webpage

Missing functions

The current filter is somewhat lacking and extracts to many links to pages that are not formatted correctly and will break the system if you try to “watch” them.

In the future it will be improved to do the following

  • Check if the name is already in the system. The sidebar uses the same html scheme as the main list

so current series will be parsed and listed twice with two ID's. Since the link is the same both entities will work, but are useless. Also they do not appear in order.

  • Check URL to filter off site links and other non valid ones.


55
56
57
# File 'lib/PinoyFilter.rb', line 55

def animes
  return PinoyFilter::SiteHandler::GetAnimeList(@url)
end

#inspectObject

Custom Inspect message.


37
38
39
# File 'lib/PinoyFilter.rb', line 37

def inspect
  return "#{self}, URL: #{@url}"
end

#latestObject

call-seq:

latest => Pinoy::Episode[]

Workings

Loads front page and fetches a list over the X most recently updated anime series. It loads a list of episodes, not anime elements, so the anime title is missing for now.

This will be updated in the future.


69
70
71
# File 'lib/PinoyFilter.rb', line 69

def latest
  return PinoyFilter::SiteHandler::GetLatest(@url)
end

#urlObject

This function will output the url supplied when .new was called. The url will have been checked and corrected for any mistakes when .new was called in the first place. call-seq:

url => string

32
33
34
# File 'lib/PinoyFilter.rb', line 32

def url
  return @url
end