Class: Geocodio::Legislator

Inherits:
Object
  • Object
show all
Defined in:
lib/geocodio/legislator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload = {}) ⇒ Legislator

Returns a new instance of Legislator.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/geocodio/legislator.rb', line 29

def initialize(payload = {})
  @type = payload['type']

  if payload['bio']
    @name = "#{payload['bio']['first_name']} #{payload['bio']['last_name']}"
    @birthday = Date.new(*payload['bio']['birthday'].split('-').map(&:to_i))
    @gender = payload['bio']['gender']
    @party = payload['bio']['party']
  end

  if payload['contact']
    @url          = payload['contact']['url']
    @address      = payload['contact']['address']
    @phone        = payload['contact']['phone']
    @contact_form = payload['contact']['contact_form']
  end

  if payload['social']
    @rss_url    = payload['social']['rss_url']
    @twitter    = payload['social']['twitter']
    @facebook   = payload['social']['facebook']
    @youtube    = payload['social']['youtube']
    @youtube_id = payload['social']['youtube_id']
  end

  if payload['references']
    @bioguide_id        = payload['references']['bioguide_id']
    @thomas_id          = payload['references']['thomas_id']
    @opensecrets_id     = payload['references']['opensecrets_id']
    @lis_id             = payload['references']['lis_id']
    @cspan_id           = payload['references']['cspan_id']
    @govtrack_id        = payload['references']['govtrack_id']
    @votesmart_id       = payload['references']['votesmart_id']
    @ballotpedia_id     = payload['references']['ballotpedia_id']
    @washington_post_id = payload['references']['washington_post_id']
    @icpsr_id           = payload['references']['icpsr_id']
    @wikipedia_id       = payload['references']['wikipedia_id']
  end
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



9
10
11
# File 'lib/geocodio/legislator.rb', line 9

def address
  @address
end

#ballotpedia_idObject (readonly)

Returns the value of attribute ballotpedia_id.



24
25
26
# File 'lib/geocodio/legislator.rb', line 24

def ballotpedia_id
  @ballotpedia_id
end

#bioguide_idObject (readonly)

Returns the value of attribute bioguide_id.



17
18
19
# File 'lib/geocodio/legislator.rb', line 17

def bioguide_id
  @bioguide_id
end

#birthdayObject (readonly)

Returns the value of attribute birthday.



5
6
7
# File 'lib/geocodio/legislator.rb', line 5

def birthday
  @birthday
end

#contact_formObject (readonly)

Returns the value of attribute contact_form.



11
12
13
# File 'lib/geocodio/legislator.rb', line 11

def contact_form
  @contact_form
end

#cspan_idObject (readonly)

Returns the value of attribute cspan_id.



21
22
23
# File 'lib/geocodio/legislator.rb', line 21

def cspan_id
  @cspan_id
end

#facebookObject (readonly)

Returns the value of attribute facebook.



14
15
16
# File 'lib/geocodio/legislator.rb', line 14

def facebook
  @facebook
end

#genderObject (readonly)

Returns the value of attribute gender.



6
7
8
# File 'lib/geocodio/legislator.rb', line 6

def gender
  @gender
end

#govtrack_idObject (readonly)

Returns the value of attribute govtrack_id.



22
23
24
# File 'lib/geocodio/legislator.rb', line 22

def govtrack_id
  @govtrack_id
end

#icpsr_idObject (readonly)

Returns the value of attribute icpsr_id.



26
27
28
# File 'lib/geocodio/legislator.rb', line 26

def icpsr_id
  @icpsr_id
end

#lis_idObject (readonly)

Returns the value of attribute lis_id.



20
21
22
# File 'lib/geocodio/legislator.rb', line 20

def lis_id
  @lis_id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/geocodio/legislator.rb', line 4

def name
  @name
end

#opensecrets_idObject (readonly)

Returns the value of attribute opensecrets_id.



19
20
21
# File 'lib/geocodio/legislator.rb', line 19

def opensecrets_id
  @opensecrets_id
end

#partyObject (readonly)

Returns the value of attribute party.



7
8
9
# File 'lib/geocodio/legislator.rb', line 7

def party
  @party
end

#phoneObject (readonly)

Returns the value of attribute phone.



10
11
12
# File 'lib/geocodio/legislator.rb', line 10

def phone
  @phone
end

#rss_urlObject (readonly)

Returns the value of attribute rss_url.



12
13
14
# File 'lib/geocodio/legislator.rb', line 12

def rss_url
  @rss_url
end

#thomas_idObject (readonly)

Returns the value of attribute thomas_id.



18
19
20
# File 'lib/geocodio/legislator.rb', line 18

def thomas_id
  @thomas_id
end

#twitterObject (readonly)

Returns the value of attribute twitter.



13
14
15
# File 'lib/geocodio/legislator.rb', line 13

def twitter
  @twitter
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/geocodio/legislator.rb', line 3

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/geocodio/legislator.rb', line 8

def url
  @url
end

#votesmart_idObject (readonly)

Returns the value of attribute votesmart_id.



23
24
25
# File 'lib/geocodio/legislator.rb', line 23

def votesmart_id
  @votesmart_id
end

#washington_post_idObject (readonly)

Returns the value of attribute washington_post_id.



25
26
27
# File 'lib/geocodio/legislator.rb', line 25

def washington_post_id
  @washington_post_id
end

#wikipedia_idObject (readonly)

Returns the value of attribute wikipedia_id.



27
28
29
# File 'lib/geocodio/legislator.rb', line 27

def wikipedia_id
  @wikipedia_id
end

#youtubeObject (readonly)

Returns the value of attribute youtube.



15
16
17
# File 'lib/geocodio/legislator.rb', line 15

def youtube
  @youtube
end

#youtube_idObject (readonly)

Returns the value of attribute youtube_id.



16
17
18
# File 'lib/geocodio/legislator.rb', line 16

def youtube_id
  @youtube_id
end