Class: Starwars::Person

Inherits:
Base show all
Defined in:
lib/starwars/resources/person.rb,
lib/starwars.rb

Overview

A People resource is an individual person or character within the Star Wars universe.

Constant Summary collapse

RESOURCE_NAME =

Define the source name in the starwars api

'people'

Constants inherited from Base

Base::BASE_URL, Base::FORMAT

Instance Method Summary collapse

Methods inherited from Base

#==, #created, #edited, fetch, #fetch, fetch_all, #id, #request_attributes, #url

Methods inherited from OpenStruct

#[]

Instance Method Details

#birth_yearString

Note:

using the in-universe standard of

The birth year of the person

BBY or ABY - Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is a battle that occurs at the end of Star Wars episode IV: A New Hope

Examples:

person.birth_year

Returns:

  • (String)


61
# File 'lib/starwars/resources/person.rb', line 61

property :birth_year

#eye_colorString

Note:

Will be “unknown” if not known or “n/a” if the person does not have an eye

The eye color of this person

Examples:

person.eye_color

Returns:

  • (String)


35
# File 'lib/starwars/resources/person.rb', line 35

property :eye_color

#filmsArray<Film>

List of films

Examples:

person.films

Returns:



101
# File 'lib/starwars/resources/person.rb', line 101

collection :films, class: Starwars::Film,  deserialize: ->(_, fragment, _) { Film.new(url: fragment) }

#genderString

Note:

Either “Male”, “Female” or “unknown”, “n/a” if the person does not have a gender

The gender of this person

Examples:

person.gender

Returns:

  • (String)


73
# File 'lib/starwars/resources/person.rb', line 73

property :gender

#hair_colorString

The hair color of this person

@note: Will be “unknown” if not known or “n/a”

if the person does not have hair

Examples:

person.hair_color

Returns:

  • (String)


47
# File 'lib/starwars/resources/person.rb', line 47

property :hair_color

#heightInteger

The height of the person in centimeters

Examples:

person.height

Returns:

  • (Integer)


80
# File 'lib/starwars/resources/person.rb', line 80

property :height, type: Integer

#homeworldArray<Planet>

List of homeworlds

Examples:

person.homeworlds

Returns:



94
# File 'lib/starwars/resources/person.rb', line 94

property :homeworld, class: Starwars::Planet, deserialize: ->(_, fragment, _) { Planet.new(url: fragment) }

#massInteger

The mass of the person in kilograms

Examples:

person.mass

Returns:

  • (Integer)


87
# File 'lib/starwars/resources/person.rb', line 87

property :mass, type: Integer

#nameString

The name of this person

Examples:

person.name

Returns:

  • (String)


16
# File 'lib/starwars/resources/person.rb', line 16

property :name

#skin_colorString

The skin color of this person

Examples:

person.skin_color

Returns:

  • (String)


23
# File 'lib/starwars/resources/person.rb', line 23

property :skin_color

#speciesArray<Specie>

List of species

Examples:

person.species

Returns:



108
# File 'lib/starwars/resources/person.rb', line 108

collection :species, class: Starwars::Specie,  deserialize: ->(_, fragment, _) { Specie.new(url: fragment) }

#starshipsArray<Starship>

List of tarships

Examples:

person.starships

Returns:



122
# File 'lib/starwars/resources/person.rb', line 122

collection :starships, class: Starwars::Starship,  deserialize: ->(_, fragment, _) { Starship.new(url: fragment) }

#vehiclesArray<Vehicle>

List of vehicles

Examples:

person.vehicles

Returns:



115
# File 'lib/starwars/resources/person.rb', line 115

collection :vehicles, class: Starwars::Vehicle,  deserialize: ->(_, fragment, _) { Vehicle.new(url: fragment) }