Class: TMDBParty::Person

Inherits:
Object
  • Object
show all
Includes:
Attributes
Defined in:
lib/tmdb_party/person.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes

included

Constructor Details

#initialize(values, tmdb) ⇒ Person

Returns a new instance of Person.



11
12
13
14
# File 'lib/tmdb_party/person.rb', line 11

def initialize(values, tmdb)
  @tmdb = tmdb
  self.attributes = values
end

Instance Attribute Details

#tmdbObject (readonly)

Returns the value of attribute tmdb.



4
5
6
# File 'lib/tmdb_party/person.rb', line 4

def tmdb
  @tmdb
end

Instance Method Details

#biographyObject



16
17
18
19
20
# File 'lib/tmdb_party/person.rb', line 16

def biography
  # HTTParty does not parse the encoded hexadecimal properly. It does not consider 000F to be a hex, but 000f is
  # A bug has been submitted about this
  read_attribute('biography').gsub("\\n", "\n").gsub(/\\u([0-9A-F]{4})/) { [$1.hex].pack("U") }
end

#get_info!Object



23
24
25
26
27
# File 'lib/tmdb_party/person.rb', line 23

def get_info!
  person = tmdb.get_person(self.id)
  @attributes.merge!(person.attributes) if person
  @loaded = true
end