Class: Person

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

Constant Summary collapse

@@senators =
[nil]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address.



2
3
4
# File 'lib/person.rb', line 2

def address
  @address
end

#cityObject

Returns the value of attribute city.



2
3
4
# File 'lib/person.rb', line 2

def city
  @city
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/person.rb', line 2

def name
  @name
end

#rdObject

Returns the value of attribute rd.



2
3
4
# File 'lib/person.rb', line 2

def rd
  @rd
end

#sdObject

Returns the value of attribute sd.



2
3
4
# File 'lib/person.rb', line 2

def sd
  @sd
end

#stateObject

Returns the value of attribute state.



2
3
4
# File 'lib/person.rb', line 2

def state
  @state
end

#zip9Object

Returns the value of attribute zip9.



2
3
4
# File 'lib/person.rb', line 2

def zip9
  @zip9
end

Instance Method Details

#full_addressObject



96
97
98
# File 'lib/person.rb', line 96

def full_address
  [self.address, self.city, self.state] * ', '
end

#readIn(str) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/person.rb', line 36

def readIn(str)
  arr=str.chomp.split("\t")
  @name = arr[0].to_s.chomp
  @address = arr[1].to_s.chomp
  @city = arr[2].to_s.chomp
  @state = arr[3].to_s.chomp
  @zip9 = arr[4].to_s.chomp
  @SD = arr[5].to_s.chomp
  @RD = arr[6].to_s.chomp
end

#senatorObject



87
88
89
# File 'lib/person.rb', line 87

def senator
  @senator ||= @@senators[self.sd.to_i]
end

#senator_nameObject



93
94
95
# File 'lib/person.rb', line 93

def senator_name
  @senator_name ||= senator[:name] if senator
end

#senator_phoneObject



90
91
92
# File 'lib/person.rb', line 90

def senator_phone
  @senator_phone ||= senator[:phone] if senator
end

#set_repsObject



81
82
83
84
85
86
# File 'lib/person.rb', line 81

def set_reps
  r = reps self
  self.rd = r[:rd]
  self.sd = r[:sd]
  r
end

#to_sObject



78
79
80
# File 'lib/person.rb', line 78

def to_s
  self.writeOut
end

#writeOutObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/person.rb', line 47

def writeOut()
  str = ""
  if (@name)
    str+=@name
    str+="\t"
  end
  if (@address)
    str+=@address
    str+="\t"
  end
  if (@city)
    str+=@city
    str+="\t"
  end
  if (@state)
    str+=@state
    str+="\t"
  end
  if (@zip9)
    str+=@zip9
    str+="\t"
  end
  if (@sd)
    str+=@sd
    str+="\t"
  end
  if (@rd)
    str+=@rd
  end
  return str.chomp;
end