Class: GovTrack::Person

Inherits:
Base show all
Defined in:
lib/govtrack/person.rb

Instance Method Summary collapse

Methods inherited from Base

#==, #eql?, find, find_by_id, find_by_uri, method_missing

Constructor Details

#initialize(attributes = {}) ⇒ Person

Returns a new instance of Person.



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

def initialize(attributes={})
  super
  @birthday = Date.parse(@birthday) if @birthday
end

Instance Method Details

#current_roleObject



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

def current_role
  @current_role.class == GovTrack::Role ? @current_role : @current_role = GovTrack::Role.find_by_id(@current_role['id'])
end

#rolesObject



13
14
15
16
17
18
19
20
21
# File 'lib/govtrack/person.rb', line 13

def roles
  if @roles[0].class == GovTrack::Role
    @roles
  else
    @roles.map! { |role_uri|
      GovTrack::Role.find_by_uri(role_uri)
    }
  end
end