Class: Jikanrb::Resources::PersonResource

Inherits:
BaseResource show all
Defined in:
lib/jikanrb/resources/person_resource.rb

Overview

Resource class for accessing Person sub-resources from the Jikan API. Provides fluent API access to person details, anime staff positions, manga work, voice acting roles, and pictures.

Examples:

Basic usage

client = Jikanrb::Client.new
person = client.person(1)
person.info                  # GET /people/1
person.info(full: true)      # GET /people/1/full
person.animes                # GET /people/1/anime
person.voices                # GET /people/1/voices

See Also:

Instance Attribute Summary

Attributes inherited from BaseResource

#id

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from Jikanrb::Resources::BaseResource

Instance Method Details

#animesHash

Returns anime staff positions for this person

Examples:

client.person(1).animes
# => { data: [{ position: "Director", anime: { mal_id: 1, title: "..." } }, ...] }

Returns:

  • (Hash)

    List of anime staff positions as IndifferentHash



44
45
46
# File 'lib/jikanrb/resources/person_resource.rb', line 44

def animes
  get("people/#{@id}/anime")
end

#info(full: false) ⇒ Hash

Returns person details

Examples:

Get basic info

client.person(1).info
# => { data: { mal_id: 1, name: "Tomokazu Seki", ... } }

Get full info

client.person(1).info(full: true)
# => { data: { mal_id: 1, name: "...", anime: [...], voices: [...] } }

Parameters:

  • full (Boolean) (defaults to: false)

    If true, returns extended information including anime, manga, and voice acting roles

Returns:

  • (Hash)

    Person data as IndifferentHash



32
33
34
35
# File 'lib/jikanrb/resources/person_resource.rb', line 32

def info(full: false)
  path = full ? "people/#{@id}/full" : "people/#{@id}"
  get(path)
end

#mangasHash

Returns manga work positions for this person

Examples:

client.person(1).mangas
# => { data: [{ position: "Story & Art", manga: { mal_id: 1, title: "..." } }, ...] }

Returns:

  • (Hash)

    List of manga work positions as IndifferentHash



55
56
57
# File 'lib/jikanrb/resources/person_resource.rb', line 55

def mangas
  get("people/#{@id}/manga")
end

#picturesHash

Returns pictures of this person

Examples:

client.person(1).pictures
# => { data: [{ jpg: { image_url: "https://..." } }, ...] }

Returns:

  • (Hash)

    List of pictures as IndifferentHash



77
78
79
# File 'lib/jikanrb/resources/person_resource.rb', line 77

def pictures
  get("people/#{@id}/pictures")
end

#voicesHash

Returns voice acting roles for this person

Examples:

client.person(1).voices
# => { data: [{ role: "Main", character: { ... }, anime: { ... } }, ...] }

Returns:

  • (Hash)

    List of voice acting roles as IndifferentHash



66
67
68
# File 'lib/jikanrb/resources/person_resource.rb', line 66

def voices
  get("people/#{@id}/voices")
end