Class: Governator::Governor

Inherits:
Object
  • Object
show all
Defined in:
lib/governator/governor.rb

Overview

Instance methods included in the Governator class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(panel) ⇒ Governor

Initializes a new Governator instance

Parameters:

  • panel (Governator::Panel)

    the Panel scraper object to pull the Governor’s data from



21
22
23
# File 'lib/governator/governor.rb', line 21

def initialize(panel)
  @panel = panel
end

Instance Attribute Details

#office_locationsObject (readonly)

Returns the value of attribute office_locations.



6
7
8
# File 'lib/governator/governor.rb', line 6

def office_locations
  @office_locations
end

#official_fullObject (readonly)

Returns the value of attribute official_full.



6
7
8
# File 'lib/governator/governor.rb', line 6

def official_full
  @official_full
end

#parsed_nameObject (readonly)

Returns the value of attribute parsed_name.



6
7
8
# File 'lib/governator/governor.rb', line 6

def parsed_name
  @parsed_name
end

#partyObject (readonly)

Returns the value of attribute party.



6
7
8
# File 'lib/governator/governor.rb', line 6

def party
  @party
end

#state_nameObject (readonly)

Returns the value of attribute state_name.



6
7
8
# File 'lib/governator/governor.rb', line 6

def state_name
  @state_name
end

#twitterObject (readonly)

Returns the value of attribute twitter.



6
7
8
# File 'lib/governator/governor.rb', line 6

def twitter
  @twitter
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/governator/governor.rb', line 6

def url
  @url
end

Class Method Details

.create(panel) ⇒ Object



11
12
13
14
15
16
# File 'lib/governator/governor.rb', line 11

def self.create(panel)
  new(panel).tap do |g|
    g.send :build
    g.send :save
  end
end

Instance Method Details

#contact_formObject



52
53
54
# File 'lib/governator/governor.rb', line 52

def contact_form
  civil_services.contact_form
end

#facebookObject



48
49
50
# File 'lib/governator/governor.rb', line 48

def facebook
  civil_services.facebook
end

#first_nameObject



56
57
58
# File 'lib/governator/governor.rb', line 56

def first_name
  parsed_name.first_name
end

#inspectObject



32
33
34
# File 'lib/governator/governor.rb', line 32

def inspect
  "#<Governator #{official_full}>"
end

#last_nameObject



68
69
70
# File 'lib/governator/governor.rb', line 68

def last_name
  parsed_name.last_name
end

#middle_nameObject



60
61
62
# File 'lib/governator/governor.rb', line 60

def middle_name
  parsed_name.middle_name
end

#nicknameObject



64
65
66
# File 'lib/governator/governor.rb', line 64

def nickname
  parsed_name.nickname
end

#photo_urlObject



44
45
46
# File 'lib/governator/governor.rb', line 44

def photo_url
  civil_services.photo_url || Governator::BASE_URI + panel.image
end

#primary_officeObject



40
41
42
# File 'lib/governator/governor.rb', line 40

def primary_office
  @_primary_office ||= office
end

#secondary_officeObject



36
37
38
# File 'lib/governator/governor.rb', line 36

def secondary_office
  @_secondary_office ||= office(prefix: :alt_)
end

#suffixObject



72
73
74
# File 'lib/governator/governor.rb', line 72

def suffix
  parsed_name.suffix
end

#to_hObject



25
26
27
28
29
30
# File 'lib/governator/governor.rb', line 25

def to_h
  syms = %i[photo_url state_name official_full url party office_locations]
  syms.each_with_object({}) do |sym, hsh|
    hsh[sym] = send(sym)
  end
end