Class: Anime
Instance Attribute Summary collapse
-
#avg_rating ⇒ Object
readonly
Returns the value of attribute avg_rating.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#n_favourites ⇒ Object
readonly
Returns the value of attribute n_favourites.
-
#n_users ⇒ Object
readonly
Returns the value of attribute n_users.
-
#nsfw ⇒ Object
readonly
Returns the value of attribute nsfw.
-
#rank_popularity ⇒ Object
readonly
Returns the value of attribute rank_popularity.
-
#rank_rating ⇒ Object
readonly
Returns the value of attribute rank_rating.
-
#rating_freq ⇒ Object
readonly
Returns the value of attribute rating_freq.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#subtype ⇒ Object
readonly
Returns the value of attribute subtype.
-
#synopsis ⇒ Object
readonly
Returns the value of attribute synopsis.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(data) ⇒ Anime
constructor
A new instance of Anime.
Methods inherited from Helpers
Constructor Details
#initialize(data) ⇒ Anime
Returns a new instance of Anime.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/foxit/objects.rb', line 27 def initialize data attributes = data['attributes'] @id = data['id'].to_i @slug = attributes['slug'] @synopsis = attributes['synopsis'] @title = attributes['canonicalTitle'] = attributes['averageRating'].to_f # TODO: need to handle nil values? rf_int = {} # mongodb needs string keys anyway, so k.to_i redundant... attributes['ratingFrequencies'].each_pair { | k, v | rf_int[k.to_i] = v.to_i } = rf_int @n_users = attributes['userCount'].to_i @n_favourites = attributes['favouritesCount'].to_i @start_date = attributes['startDate'] @end_date = attributes['endDate'] @rank_popularity = attributes['popularityRank'].to_i = attributes['ratingRank'].to_i @subtype = attributes['subtype'] @showtype = attributes['showType'] @nsfw = attributes['nsfw'] # TODO: convert to bool? end |
Instance Attribute Details
#avg_rating ⇒ Object (readonly)
Returns the value of attribute avg_rating.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def end_date @end_date end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def id @id end |
#n_favourites ⇒ Object (readonly)
Returns the value of attribute n_favourites.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def n_favourites @n_favourites end |
#n_users ⇒ Object (readonly)
Returns the value of attribute n_users.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def n_users @n_users end |
#nsfw ⇒ Object (readonly)
Returns the value of attribute nsfw.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def nsfw @nsfw end |
#rank_popularity ⇒ Object (readonly)
Returns the value of attribute rank_popularity.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def rank_popularity @rank_popularity end |
#rank_rating ⇒ Object (readonly)
Returns the value of attribute rank_rating.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def end |
#rating_freq ⇒ Object (readonly)
Returns the value of attribute rating_freq.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def slug @slug end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def start_date @start_date end |
#subtype ⇒ Object (readonly)
Returns the value of attribute subtype.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def subtype @subtype end |
#synopsis ⇒ Object (readonly)
Returns the value of attribute synopsis.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def synopsis @synopsis end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
23 24 25 |
# File 'lib/foxit/objects.rb', line 23 def title @title end |