Class: BU::Scanlators
- Inherits:
-
Object
- Object
- BU::Scanlators
- Defined in:
- lib/bu/scanlators.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #active ⇒ Object
- #all ⇒ Object
- #count ⇒ Object
-
#initialize(url, api, scanlators = nil) ⇒ Scanlators
constructor
A new instance of Scanlators.
- #irc_channels ⇒ Object
- #search(term) ⇒ Object
- #with_irc ⇒ Object
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
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
4 5 6 |
# File 'lib/bu/scanlators.rb', line 4 def doc @doc end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/bu/scanlators.rb', line 4 def url @url end |
Instance Method Details
#active ⇒ Object
29 30 31 32 |
# File 'lib/bu/scanlators.rb', line 29 def active @active ||= Scanlators.new(url, @api, scanlators.select { |s| s[:active] }) end |
#all ⇒ Object
16 17 18 |
# File 'lib/bu/scanlators.rb', line 16 def all scanlators end |
#count ⇒ Object
12 13 14 |
# File 'lib/bu/scanlators.rb', line 12 def count @count ||= all.length end |
#irc_channels ⇒ Object
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_irc ⇒ Object
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 |