Class: MyRepresentatives::Electorate

Inherits:
Object
  • Object
show all
Includes:
Hashable
Defined in:
lib/my_representatives/electorate.rb

Defined Under Namespace

Classes: ElectorateNameMissingError, Error, StateNameInvalidError, StateNameMissingError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Electorate

Returns a new instance of Electorate.



12
13
14
15
# File 'lib/my_representatives/electorate.rb', line 12

def initialize(name)
  raise ElectorateNameMissingError unless name && name.is_a?(String)
  @name = name
end

Instance Attribute Details

#houseObject

Returns the value of attribute house.



10
11
12
# File 'lib/my_representatives/electorate.rb', line 10

def house
  @house
end

#lower_houseObject

Returns the value of attribute lower_house.



10
11
12
# File 'lib/my_representatives/electorate.rb', line 10

def lower_house
  @lower_house
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/my_representatives/electorate.rb', line 10

def name
  @name
end

#stateObject

Returns the value of attribute state.



10
11
12
# File 'lib/my_representatives/electorate.rb', line 10

def state
  @state
end

#state_governmentObject

Returns the value of attribute state_government.



10
11
12
# File 'lib/my_representatives/electorate.rb', line 10

def state_government
  @state_government
end

Instance Method Details

#commonwealth_lower!(state) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/my_representatives/electorate.rb', line 21

def commonwealth_lower!(state)
  raise StateNameMissingError unless state
  raise StateNameInvalidError unless MyRepresentatives::Static::STATES.include?(state)
  self.name             = self.name
  self.house            = "House of Representatives"
  self.state            = state
  self.state_government = false
  self.lower_house      = true
end

#commonwealth_upper!(state) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/my_representatives/electorate.rb', line 31

def commonwealth_upper!(state)
  raise StateNameMissingError unless state
  raise StateNameInvalidError unless MyRepresentatives::Static::STATES.include?(state)
  self.name             = self.name
  self.house            = "Senate"
  self.state            = state
  self.state_government = false
  self.lower_house      = false
end

#state_act_lower!Object



41
42
43
44
45
46
47
# File 'lib/my_representatives/electorate.rb', line 41

def state_act_lower!
  self.name             = self.name
  self.house            = "Legislative Assembly"
  self.state            = "ACT"
  self.state_government = true
  self.lower_house      = true
end

#state_nsw_lower!Object



49
50
51
52
53
54
55
# File 'lib/my_representatives/electorate.rb', line 49

def state_nsw_lower!
  self.name             = self.name
  self.house            = "Legislative Assembly"
  self.state            = "NSW"
  self.state_government = true
  self.lower_house      = true
end

#state_nsw_upper!Object



57
58
59
60
61
62
63
# File 'lib/my_representatives/electorate.rb', line 57

def state_nsw_upper!
  self.name             = self.name
  self.house            = "Legislative Council"
  self.state            = "NSW"
  self.state_government = true
  self.lower_house      = false
end

#state_nt_lower!Object



65
66
67
68
69
70
71
# File 'lib/my_representatives/electorate.rb', line 65

def state_nt_lower!
  self.name             = self.name
  self.house            = "Legislative Assembly"
  self.state            = "NT"
  self.state_government = true
  self.lower_house      = true
end

#state_qld_lower!Object



73
74
75
76
77
78
79
# File 'lib/my_representatives/electorate.rb', line 73

def state_qld_lower!
  self.name             = self.name
  self.house            = "Legislative Assembly"
  self.state            = "QLD"
  self.state_government = true
  self.lower_house      = true
end

#state_sa_lower!Object



81
82
83
84
85
86
87
# File 'lib/my_representatives/electorate.rb', line 81

def state_sa_lower!
  self.name             = self.name
  self.house            = "House of Assembly"
  self.state            = "SA"
  self.state_government = true
  self.lower_house      = true
end

#state_sa_upper!Object



89
90
91
92
93
94
95
# File 'lib/my_representatives/electorate.rb', line 89

def state_sa_upper!
  self.name             = self.name
  self.house            = "Legislative Council"
  self.state            = "SA"
  self.state_government = true
  self.lower_house      = false
end

#state_tas_lower!Object



97
98
99
100
101
102
103
# File 'lib/my_representatives/electorate.rb', line 97

def state_tas_lower!
  self.name             = self.name
  self.house            = "House of Assembly"
  self.state            = "TAS"
  self.state_government = true
  self.lower_house      = true
end

#state_tas_upper!Object



105
106
107
108
109
110
111
# File 'lib/my_representatives/electorate.rb', line 105

def state_tas_upper!
  self.name             = self.name
  self.house            = "Legislative Council"
  self.state            = "TAS"
  self.state_government = true
  self.lower_house      = false
end

#state_vic_lower!Object



113
114
115
116
117
118
119
# File 'lib/my_representatives/electorate.rb', line 113

def state_vic_lower!
  self.name             = self.name
  self.house            = "Legislative Assembly"
  self.state            = "VIC"
  self.state_government = true
  self.lower_house      = true
end

#state_vic_upper!Object



121
122
123
124
125
126
127
# File 'lib/my_representatives/electorate.rb', line 121

def state_vic_upper!
  self.name             = self.name
  self.house            = "Legislative Council"
  self.state            = "VIC"
  self.state_government = true
  self.lower_house      = false
end

#state_wa_lower!Object



129
130
131
132
133
134
135
# File 'lib/my_representatives/electorate.rb', line 129

def state_wa_lower!
  self.name             = self.name
  self.house            = "Legislative Assembly"
  self.state            = "WA"
  self.state_government = true
  self.lower_house      = true
end

#state_wa_upper!Object



137
138
139
140
141
142
143
# File 'lib/my_representatives/electorate.rb', line 137

def state_wa_upper!
  self.name             = self.name
  self.house            = "Legislative Council"
  self.state            = "WA"
  self.state_government = true
  self.lower_house      = false
end

#to_hashObject



17
18
19
# File 'lib/my_representatives/electorate.rb', line 17

def to_hash
  super
end