class Entry

Attributes

distro_episode[R]
distro_meta[R]
episode[R]
hashless[R]
last_ep[R]
meta[R]
series[R]
subber[R]
title[R]

Public Class Methods

new(title, link=nil) click to toggle source
# File lib/nyaa_anime/entry.rb, line 7
def initialize(title, link=nil)
  @title = title
  @link = link
  match = @title.scan(/\A(\[[^\[\]]+\])?[_\s]*(.+?)[_\s]*-?[_\s]*(\d+(\.\d+)?(v\d+)?|\d+-\d+)[_\s]+((?!-).+?)[_\s]*(\[\w{8,}\])?[_\s]*(\.\w+)*\z/)
  if match[0].nil?
    match[0] = ['undefined', 'undefined', 'undefined', nil, nil, 'undefined']
  end
  @subber, @series, @episode, @meta = match[0].values_at(0, 1, 2, 5)
  @episode, @last_ep = @episode.split("-").map { |ep| ep.to_i }
  @last_ep ||= @episode
  @distro_episode = "#{@subber} #{@series} #{@episode}"
  @distro_meta = "#{@subber} #{@series} #{@meta}"
  @hashless = "#{@subber} #{@series} #{@episode} #{@meta}"
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/nyaa_anime/entry.rb, line 27
def <=>(other)
  if @title == other.title
    @link <=> other.link
  else
    @title <=> other.title
  end
end
==(other) click to toggle source
# File lib/nyaa_anime/entry.rb, line 22
def ==(other)
  @title == other.title &&
    @link == other.link
end
first_ep() click to toggle source
# File lib/nyaa_anime/entry.rb, line 39
def first_ep
  @episode
end
to_s() click to toggle source
# File lib/nyaa_anime/entry.rb, line 35
def to_s
  @hashless
end