Class: ANN_Anime

Inherits:
ANN_Media show all
Defined in:
lib/ann_wrapper/ann_anime.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Returns:

  • ([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)

Returns:

  • ([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

Returns:



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

Returns:

  • (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

#idString

Returns anime id

Returns:

  • (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

Returns:

  • ([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)

Returns:

  • ([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

Returns:



44
45
46
# File 'lib/ann_wrapper/ann_anime.rb', line 44

def ratings
	super @ann_anime
end

#staff[ANN_Staff]

Returns array of ANN_Staff

Returns:

  • ([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_hHash

Returns hash of self.

Returns:

  • (Hash)

    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

#typeString

Returns anime type

Returns:

  • (String)

    returns anime type



39
40
41
# File 'lib/ann_wrapper/ann_anime.rb', line 39

def type
	@type ||= @ann_anime['type']
end