Class: Cwc::Office
- Inherits:
-
Object
- Object
- Cwc::Office
- Defined in:
- lib/cwc/office.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
- #house? ⇒ Boolean
- #house_district ⇒ Object
-
#initialize(code) ⇒ Office
constructor
A new instance of Office.
- #senate? ⇒ Boolean
- #senate_class ⇒ Object
- #state ⇒ Object
Constructor Details
#initialize(code) ⇒ Office
Returns a new instance of Office.
5 6 7 |
# File 'lib/cwc/office.rb', line 5 def initialize(code) @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/cwc/office.rb', line 3 def code @code end |
Instance Method Details
#house? ⇒ Boolean
9 10 11 |
# File 'lib/cwc/office.rb', line 9 def house? code[0, 1] == "H" end |
#house_district ⇒ Object
17 18 19 |
# File 'lib/cwc/office.rb', line 17 def house_district code[-2..-1].to_i end |
#senate? ⇒ Boolean
13 14 15 |
# File 'lib/cwc/office.rb', line 13 def senate? code[0, 1] == "S" end |
#senate_class ⇒ Object
21 22 23 |
# File 'lib/cwc/office.rb', line 21 def senate_class code[-1..-1].to_i + 1 end |
#state ⇒ Object
25 26 27 |
# File 'lib/cwc/office.rb', line 25 def state code[1..2] end |