Class: Representative

Inherits:
Hash
  • Object
show all
Defined in:
lib/get-your-rep/representative.rb

Overview

Stores rep info in key/value pairs, and makes values accessible by instance method.

Instance Method Summary collapse

Methods inherited from Hash

#to_del, #to_rep

Instance Method Details

#address_1Object

Get the :address_1 value.



81
82
83
# File 'lib/get-your-rep/representative.rb', line 81

def address_1
  @address_1 = self[:address_1]
end

#address_1=(value) ⇒ Object

Set the :address_1 value.



86
87
88
89
# File 'lib/get-your-rep/representative.rb', line 86

def address_1=(value)
  @address_1 = value
  self[:address_1] = @address_1
end

#address_2Object

Get the :address_2 value.



92
93
94
# File 'lib/get-your-rep/representative.rb', line 92

def address_2
  @address_2 = self[:address_2]
end

#address_2=(value) ⇒ Object

Set the :address_2 value.



97
98
99
100
# File 'lib/get-your-rep/representative.rb', line 97

def address_2=(value)
  @address_2 = value
  self[:address_2] = @address_2
end

#address_3Object

Get the :address_3 value.



103
104
105
# File 'lib/get-your-rep/representative.rb', line 103

def address_3
  @address_3 = self[:address_3]
end

#address_3=(value) ⇒ Object

Set the :address_3 value.



108
109
110
111
# File 'lib/get-your-rep/representative.rb', line 108

def address_3=(value)
  @address_3 = value
  self[:address_3] = @address_3
end

#business_cardObject

Maps attributes to a simple array for easy printing, iteration, and display. It uses #each rather than #map so it can skip over nil values without mapping them.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/get-your-rep/representative.rb', line 23

def business_card
  card = []
  self.each do |key, value|
    next if value.nil?
    if key == :facebook || key == :twitter || key == :youtube || key == :googleplus
      card << "#{key.to_s.capitalize}: #{value}"
    else
      card << "#{value}"
    end
  end
  card
end

#emailObject

Get the :email value.



114
115
116
# File 'lib/get-your-rep/representative.rb', line 114

def email
  @email = self[:email]
end

#email=(value) ⇒ Object

Set the :email value.



119
120
121
122
# File 'lib/get-your-rep/representative.rb', line 119

def email=(value)
  @email = value
  self[:email] = @email
end

#facebookObject

Get the :facebook value.



158
159
160
# File 'lib/get-your-rep/representative.rb', line 158

def facebook
  @facebook = self[:facebook]
end

#facebook=(value) ⇒ Object

Set the :facebook value.



163
164
165
166
# File 'lib/get-your-rep/representative.rb', line 163

def facebook=(value)
  @facebook = value
  self[:facebook] = @facebook
end

#first_nameObject

Strips the first name out of the full name.



5
6
7
8
9
10
11
# File 'lib/get-your-rep/representative.rb', line 5

def first_name
  if (name.split.count > 3) || (name.split[-2].downcase == name.split[-2])
    name.split[0..-3].join(' ')
  else
    name.split[0..-2].join(' ')
  end
end

#googleplusObject

Get the :googleplus value.



180
181
182
# File 'lib/get-your-rep/representative.rb', line 180

def googleplus
  @googleplus = self[:googleplus]
end

#googleplus=(value) ⇒ Object

Set the :googleplus value.



185
186
187
188
# File 'lib/get-your-rep/representative.rb', line 185

def googleplus=(value)
  @googleplus = value
  self[:googleplus] = @googleplus
end

#last_nameObject

Strips the surname out of the full name.



14
15
16
17
18
19
20
# File 'lib/get-your-rep/representative.rb', line 14

def last_name
  if (name.split.count > 3) || (name.split[-2].downcase == name.split[-2])
    name.split[-2..-1].join(' ')
  else
    name.split.last
  end
end

#nameObject

Get the :name value.



37
38
39
# File 'lib/get-your-rep/representative.rb', line 37

def name
  @name = self[:name]
end

#name=(value) ⇒ Object

Set the :name value.



42
43
44
45
# File 'lib/get-your-rep/representative.rb', line 42

def name=(value)
  @name = value
  self[:name] = @name
end

#officeObject

Get the :office value.



48
49
50
# File 'lib/get-your-rep/representative.rb', line 48

def office
  @office = self[:office]
end

#office=(value) ⇒ Object

Set the :office value.



53
54
55
56
# File 'lib/get-your-rep/representative.rb', line 53

def office=(value)
  @office = value
  self[:office] = @office
end

#partyObject

Get the :party value.



59
60
61
# File 'lib/get-your-rep/representative.rb', line 59

def party
  @party = self[:party]
end

#party=(value) ⇒ Object

Set the :party value.



64
65
66
67
# File 'lib/get-your-rep/representative.rb', line 64

def party=(value)
  @party = value
  self[:party] = @party
end

#phoneObject

Get the :phone value.



70
71
72
# File 'lib/get-your-rep/representative.rb', line 70

def phone
  @phone = self[:phone]
end

#phone=(value) ⇒ Object

Set the :phone value.



75
76
77
78
# File 'lib/get-your-rep/representative.rb', line 75

def phone=(value)
  @phone = value
  self[:phone] = @phone
end

#photoObject

Get the :photo value.



136
137
138
# File 'lib/get-your-rep/representative.rb', line 136

def photo
  @photo = self[:photo]
end

#photo=(value) ⇒ Object

Set the :photo value.



141
142
143
144
# File 'lib/get-your-rep/representative.rb', line 141

def photo=(value)
  @photo = value
  self[:photo] = @photo
end

#twitterObject

Get the :twitter value.



147
148
149
# File 'lib/get-your-rep/representative.rb', line 147

def twitter
  @twitter = self[:twitter]
end

#twitter=(value) ⇒ Object

Set the :twitter value.



152
153
154
155
# File 'lib/get-your-rep/representative.rb', line 152

def twitter=(value)
  @twitter = value
  self[:twitter] = @twitter
end

#urlObject

Get the :url value.



125
126
127
# File 'lib/get-your-rep/representative.rb', line 125

def url
  @url = self[:url]
end

#url=(value) ⇒ Object

Set the :url value.



130
131
132
133
# File 'lib/get-your-rep/representative.rb', line 130

def url=(value)
  @url = value
  self[:url] = @url
end

#youtubeObject

Get the :youtube value.



169
170
171
# File 'lib/get-your-rep/representative.rb', line 169

def youtube
  @youtube = self[:youtube]
end

#youtube=(value) ⇒ Object

Set the :youtube value.



174
175
176
177
# File 'lib/get-your-rep/representative.rb', line 174

def youtube=(value)
  @youtube = value
  self[:youtube] = @youtube
end