Class: Allocine::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/allocine_parser/person.rb

Instance Method Summary collapse

Constructor Details

#initialize(allocine_id, title = nil) ⇒ Person

s = Allocine::Person.new(41339) e = s.name


8
9
10
11
# File 'lib/allocine_parser/person.rb', line 8

def initialize(allocine_id, title = nil)
  @id = allocine_id
  @url = "http://api.allocine.fr/rest/v3/person?partner=YW5kcm9pZC12M3M&profile=large&code=#{allocine_id}&format=json"
end

Instance Method Details

#activity_shortObject

Returns activities of person


31
32
33
# File 'lib/allocine_parser/person.rb', line 31

def activity_short
  document["activityShort"] rescue nil
end

#biography(short = true) ⇒ Object

Returns biography of person


36
37
38
# File 'lib/allocine_parser/person.rb', line 36

def biography(short = true)
  short == true ? document["biographyShort"] : document["biography"] rescue nil
end

#birth_dateObject

Returns birth_date of person


41
42
43
# File 'lib/allocine_parser/person.rb', line 41

def birth_date
  document["birthDate"] rescue nil
end

#genderObject

Returns gender of person


24
25
26
27
28
# File 'lib/allocine_parser/person.rb', line 24

def gender
  # 1 => male
  # 0 => female
  document["gender"] rescue nil
end

#nameObject

Returns name of person


14
15
16
# File 'lib/allocine_parser/person.rb', line 14

def name
  document["name"]["given"] + " " +document["name"]["family"] rescue nil
end

#nationalityObject

Returns nationality of person


19
20
21
# File 'lib/allocine_parser/person.rb', line 19

def nationality
  document["nationality"].collect {|nation| nation["$"]} rescue nil
end

#pictureObject

Returns picture of person


46
47
48
# File 'lib/allocine_parser/person.rb', line 46

def picture
  document["picture"]["href"] rescue nil
end