class Representative
Stores rep info in key/value pairs, and makes values accessible by instance method.
Public Instance Methods
Get the :address_1 value.
# File lib/get-your-rep/representative.rb, line 81 def address_1 @address_1 = self[:address_1] end
Set the :address_1 value.
# File lib/get-your-rep/representative.rb, line 86 def address_1=(value) @address_1 = value self[:address_1] = @address_1 end
Get the :address_2 value.
# File lib/get-your-rep/representative.rb, line 92 def address_2 @address_2 = self[:address_2] end
Set the :address_2 value.
# File lib/get-your-rep/representative.rb, line 97 def address_2=(value) @address_2 = value self[:address_2] = @address_2 end
Get the :address_3 value.
# File lib/get-your-rep/representative.rb, line 103 def address_3 @address_3 = self[:address_3] end
Set the :address_3 value.
# File lib/get-your-rep/representative.rb, line 108 def address_3=(value) @address_3 = value self[:address_3] = @address_3 end
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.
# 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
Get the :email value.
# File lib/get-your-rep/representative.rb, line 114 def email @email = self[:email] end
Set the :email value.
# File lib/get-your-rep/representative.rb, line 119 def email=(value) @email = value self[:email] = @email end
Get the :facebook value.
# File lib/get-your-rep/representative.rb, line 158 def facebook @facebook = self[:facebook] end
Set the :facebook value.
# File lib/get-your-rep/representative.rb, line 163 def facebook=(value) @facebook = value self[:facebook] = @facebook end
Strips the first name out of the full name.
# 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
Get the :googleplus value.
# File lib/get-your-rep/representative.rb, line 180 def googleplus @googleplus = self[:googleplus] end
Set the :googleplus value.
# File lib/get-your-rep/representative.rb, line 185 def googleplus=(value) @googleplus = value self[:googleplus] = @googleplus end
Strips the surname out of the full name.
# 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
Get the :name value.
# File lib/get-your-rep/representative.rb, line 37 def name @name = self[:name] end
Set the :name value.
# File lib/get-your-rep/representative.rb, line 42 def name=(value) @name = value self[:name] = @name end
Get the :office value.
# File lib/get-your-rep/representative.rb, line 48 def office @office = self[:office] end
Set the :office value.
# File lib/get-your-rep/representative.rb, line 53 def office=(value) @office = value self[:office] = @office end
Get the :party value.
# File lib/get-your-rep/representative.rb, line 59 def party @party = self[:party] end
Set the :party value.
# File lib/get-your-rep/representative.rb, line 64 def party=(value) @party = value self[:party] = @party end
Get the :phone value.
# File lib/get-your-rep/representative.rb, line 70 def phone @phone = self[:phone] end
Set the :phone value.
# File lib/get-your-rep/representative.rb, line 75 def phone=(value) @phone = value self[:phone] = @phone end
Get the :photo value.
# File lib/get-your-rep/representative.rb, line 136 def photo @photo = self[:photo] end
Set the :photo value.
# File lib/get-your-rep/representative.rb, line 141 def photo=(value) @photo = value self[:photo] = @photo end
Get the :twitter value.
# File lib/get-your-rep/representative.rb, line 147 def twitter @twitter = self[:twitter] end
Set the :twitter value.
# File lib/get-your-rep/representative.rb, line 152 def twitter=(value) @twitter = value self[:twitter] = @twitter end
Get the :url value.
# File lib/get-your-rep/representative.rb, line 125 def url @url = self[:url] end
Set the :url value.
# File lib/get-your-rep/representative.rb, line 130 def url=(value) @url = value self[:url] = @url end
Get the :youtube value.
# File lib/get-your-rep/representative.rb, line 169 def youtube @youtube = self[:youtube] end
Set the :youtube value.
# File lib/get-your-rep/representative.rb, line 174 def youtube=(value) @youtube = value self[:youtube] = @youtube end