Class: ANN_Anime
- Defined in:
- lib/ann_wrapper/ann_anime.rb
Instance Attribute Summary collapse
-
#ann_anime ⇒ Object
writeonly
ann_anime Nokogiri object.
Instance Method Summary collapse
-
#cast ⇒ [ANN_Cast]
Returns array of ANN_Cast.
-
#ed_theme ⇒ [String]
Returns ed theme(s).
-
#episodes ⇒ [ANN_Episode]
Returns array of ANN_Episode.
-
#find_info(key) ⇒ Nokogiri::XML::NodeSet
Return all info with provided key.
-
#id ⇒ String
Returns anime id.
-
#initialize(ann_anime) ⇒ ANN_Anime
constructor
initialize and create info methods.
-
#num_episodes ⇒ [String]
Returns number of episodes.
-
#op_theme ⇒ [String]
Returns op theme(s).
-
#ratings ⇒ [ANN_Rating]
Returns array of ANN_Episode.
-
#staff ⇒ [ANN_Staff]
Returns array of ANN_Staff.
-
#to_h ⇒ Hash
Hash of self.
-
#type ⇒ String
Returns anime type.
Methods inherited from ANN_Media
#alt_titles, #create_methods, #genres, #images, #synopsis, #themes, #title, #vintage
Constructor Details
#initialize(ann_anime) ⇒ ANN_Anime
initialize and create info methods
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ann_wrapper/ann_anime.rb', line 9 def initialize(ann_anime) @ann_anime = ann_anime # information available from detail @info = Hash.new @info[:title] = "Main title" @info[:synopsis] = "Plot Summary" @info[:num_episodes] = "Number of episodes" @info[:genres] = "Genres" @info[:themes] = "Themes" @info[:vintage] = "Vintage" @info[:op_theme] = "Opening Theme" @info[:ed_theme] = "Ending Theme" # create methods create_methods(@ann_anime, @info) end |
Instance Attribute Details
#ann_anime=(value) ⇒ Object (writeonly)
ann_anime Nokogiri object
5 6 7 |
# File 'lib/ann_wrapper/ann_anime.rb', line 5 def ann_anime=(value) @ann_anime = value end |
Instance Method Details
#cast ⇒ [ANN_Cast]
Returns array of ANN_Cast
57 58 59 60 61 62 63 |
# File 'lib/ann_wrapper/ann_anime.rb', line 57 def cast @cast ||= @ann_anime.xpath("./cast").map do |s| role = s.at_xpath("role") person = s.at_xpath("person") ANN_Cast.new(person['id'], role.content, person.content, s['lang']) end end |
#ed_theme ⇒ [String]
Returns ed theme(s)
84 |
# File 'lib/ann_wrapper/ann_anime.rb', line 84 def ed_theme; end |
#episodes ⇒ [ANN_Episode]
Returns array of ANN_Episode
49 50 51 52 53 54 |
# File 'lib/ann_wrapper/ann_anime.rb', line 49 def episodes @episodes ||= @ann_anime.xpath("./episode").map do |e| title = e.at_xpath("title") ANN_Episode.new(e['num'], title.content, title['lang']) end end |
#find_info(key) ⇒ Nokogiri::XML::NodeSet
Return all info with provided key
29 30 31 |
# File 'lib/ann_wrapper/ann_anime.rb', line 29 def find_info(key) super(@ann_anime, key) end |
#id ⇒ String
Returns anime id
34 35 36 |
# File 'lib/ann_wrapper/ann_anime.rb', line 34 def id @id ||= @ann_anime['id'] end |
#num_episodes ⇒ [String]
Returns number of episodes
80 |
# File 'lib/ann_wrapper/ann_anime.rb', line 80 def num_episodes; end |
#op_theme ⇒ [String]
Returns op theme(s)
82 |
# File 'lib/ann_wrapper/ann_anime.rb', line 82 def op_theme; end |
#ratings ⇒ [ANN_Rating]
Returns array of ANN_Episode
44 45 46 |
# File 'lib/ann_wrapper/ann_anime.rb', line 44 def super @ann_anime end |
#staff ⇒ [ANN_Staff]
Returns array of ANN_Staff
66 67 68 |
# File 'lib/ann_wrapper/ann_anime.rb', line 66 def staff super @ann_anime end |
#to_h ⇒ Hash
Returns hash of self.
71 72 73 74 |
# File 'lib/ann_wrapper/ann_anime.rb', line 71 def to_h # create hash excluding some methods to_hash([:to_h, :ann_anime=, :find_info]) end |
#type ⇒ String
Returns anime type
39 40 41 |
# File 'lib/ann_wrapper/ann_anime.rb', line 39 def type @type ||= @ann_anime['type'] end |