Class: BU::Scanlators

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, api, scanlators = nil) ⇒ Scanlators

Returns a new instance of Scanlators.



5
6
7
8
9
10
# File 'lib/bu/scanlators.rb', line 5

def initialize(url, api, scanlators = nil)
  @url = url
  @api = api
  @doc = @api.doc(url_for_page(1))
  @scanlators = scanlators
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



4
5
6
# File 'lib/bu/scanlators.rb', line 4

def doc
  @doc
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/bu/scanlators.rb', line 4

def url
  @url
end

Instance Method Details

#activeObject



29
30
31
32
# File 'lib/bu/scanlators.rb', line 29

def active
  @active ||= 
    Scanlators.new(url, @api, scanlators.select { |s| s[:active] }) 
end

#allObject



16
17
18
# File 'lib/bu/scanlators.rb', line 16

def all
  scanlators
end

#countObject



12
13
14
# File 'lib/bu/scanlators.rb', line 12

def count
  @count ||= all.length
end

#irc_channelsObject



20
21
22
# File 'lib/bu/scanlators.rb', line 20

def irc_channels
  scanlators.map { |s| s[:irc] }
end

#search(term) ⇒ Object



34
35
36
# File 'lib/bu/scanlators.rb', line 34

def search(term)
  scanlators.select { |s| s[:name] =~ /#{term}/i }
end

#with_ircObject



24
25
26
27
# File 'lib/bu/scanlators.rb', line 24

def with_irc
  @with_irc ||=
    Scanlators.new(url, @api, scanlators.select { |s| s[:irc][0] }) 
end