Class: Mangdown::MangaList

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

Overview

a list of manga

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*uri, mangas: []) ⇒ MangaList



12
13
14
15
16
17
18
19
# File 'lib/mangdown/manga_list.rb', line 12

def initialize(*uri, mangas: [])
  @mangas = mangas
  if mangas.empty?
    uri.each {|uri| get_mangas(uri)} 
  else
    @mangas.map! { |hash| MDHash.new(hash) }
  end
end

Instance Attribute Details

#mangasObject (readonly)

Returns the value of attribute mangas.



6
7
8
# File 'lib/mangdown/manga_list.rb', line 6

def mangas
  @mangas
end

Class Method Details

.from_data(mangas) ⇒ Object



8
9
10
# File 'lib/mangdown/manga_list.rb', line 8

def self.from_data(mangas)
  new(nil, mangas: mangas) 
end

Instance Method Details

#to_yamlObject



21
22
23
# File 'lib/mangdown/manga_list.rb', line 21

def to_yaml
  @mangas.map(&:to_hash).to_yaml
end