Module: Realnick
- Defined in:
- lib/realnick.rb,
lib/realnick/version.rb
Constant Summary collapse
- VERSION =
realnick version
"0.1.3"
Class Method Summary collapse
-
.fetch(method = 'popular_anime') ⇒ Object
Main method.
Class Method Details
.fetch(method = 'popular_anime') ⇒ Object
Main method. With this you fetch a nick based on the method. Available methods: popular_anime, top_anime, upcoming_anime, just_added_anime
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/realnick.rb', line 13 def fetch(method = 'popular_anime') methods = ['popular_anime', 'top_anime', 'upcoming_anime'] raise ArgumentError, 'method not found' unless methods.include? method case method when 'top_anime' @url = 'http://mal-api.com/anime/top' when 'popular_anime' @url = 'http://mal-api.com/anime/popular' when 'upcoming_anime' @url = 'http://mal-api.com/anime/upcoming' end anime = JSON.parse(open(@url).read).sample url = URI::encode("http://myanimelist.net/anime/#{anime['id']}/#{anime['title']}/characters") characters = parse_characters(url) # randomize a little more by adding a suffix characters.shuffle.map{ |c| c << ["", "-san", "-sama", "-sensei"].sample } end |