Class: MyAnimeList::Anime
- Inherits:
-
Object
- Object
- MyAnimeList::Anime
- Defined in:
- lib/myanimelist/anime.rb
Instance Method Summary collapse
- #get_search(name) ⇒ Object
-
#initialize(options = {}) ⇒ Anime
constructor
A new instance of Anime.
- #parse_xml(response) ⇒ Object
- #search(name) ⇒ Object
- #serialize(data) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Anime
Returns a new instance of Anime.
4 5 6 7 |
# File 'lib/myanimelist/anime.rb', line 4 def initialize(={}) @myanimelist_username = [:username] @myanimelist_password = [:password] end |
Instance Method Details
#get_search(name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/myanimelist/anime.rb', line 13 def get_search(name) response = RestClient::Request.new( method: :get, url: "https://myanimelist.net/api/anime/search.xml?q=#{CGI::escape name}", user: @myanimelist_username, password: @myanimelist_password, content_type: :xml ).execute parse_xml response end |
#parse_xml(response) ⇒ Object
24 25 26 |
# File 'lib/myanimelist/anime.rb', line 24 def parse_xml(response) serialize Hash.from_xml response end |
#search(name) ⇒ Object
9 10 11 |
# File 'lib/myanimelist/anime.rb', line 9 def search(name) get_search(name) end |
#serialize(data) ⇒ Object
28 29 30 31 |
# File 'lib/myanimelist/anime.rb', line 28 def serialize(data) result = MyAnimeList::Serializer.new data, 'anime' result.fetch end |