class IceAndFireApi::Character

Attributes

aliases[R]
allegiances[R]
books[R]
born[R]
culture[R]
died[R]
father[R]
gender[R]
mother[R]
name[R]
played_by[R]
pov_books[R]
spouse[R]
titles[R]
tv_series[R]
url[R]

Public Class Methods

find(id) click to toggle source
# File lib/ice_and_fire_api/character.rb, line 27
def self.find(id)
  response = Faraday.get("#{IceAndFireApi::API_URL}/characters/#{id}")
  attributes = JSON.parse(response.body)
  new(attributes)
end
find_by(query_parameters) click to toggle source
# File lib/ice_and_fire_api/character.rb, line 33
def self.find_by(query_parameters)
  character_query = URI.encode_www_form(query_parameters)
  response = Faraday.get("#{IceAndFireApi::API_URL}/characters?#{character_query}")
  attributes_response = JSON.parse(response.body)
  attributes_array = []
  attributes_response.each do |attributes|
    attributes_array << new(attributes)
  end
  attributes_array
end
new(attributes) click to toggle source
# File lib/ice_and_fire_api/character.rb, line 8
def initialize(attributes)
  @url = attributes['url']
  @name = attributes['name']
  @gender = attributes['gender']
  @culture = attributes['culture']
  @born = attributes['born']
  @died = attributes['died']
  @titles = attributes['titles']
  @aliases = attributes['aliases']
  @father = attributes['father']
  @mother = attributes['mother']
  @spouse = attributes['spouse']
  @allegiances = attributes['allegiances']
  @books = attributes['books']
  @pov_books = attributes['povBooks']
  @tv_series = attributes['tvSeries']
  @played_by = attributes['playedBy']
end