Class: Cwc::Office

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#codeObject (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

Returns:

  • (Boolean)


9
10
11
# File 'lib/cwc/office.rb', line 9

def house?
  code[0, 1] == "H"
end

#house_districtObject



17
18
19
# File 'lib/cwc/office.rb', line 17

def house_district
  code[-2..-1].to_i
end

#senate?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/cwc/office.rb', line 13

def senate?
  code[0, 1] == "S"
end

#senate_classObject



21
22
23
# File 'lib/cwc/office.rb', line 21

def senate_class
  code[-1..-1].to_i + 1
end

#stateObject



25
26
27
# File 'lib/cwc/office.rb', line 25

def state
  code[1..2]
end