Class: Ward::Data
- Inherits:
-
Object
- Object
- Ward::Data
- Defined in:
- lib/ward/ward_data.rb
Instance Attribute Summary (collapse)
-
- (Object) data
readonly
Returns the value of attribute data.
Instance Method Summary (collapse)
-
- (Object) alderman
Alderman Hash.
-
- (Data) initialize(data)
constructor
A new instance of Data.
-
- (Object) number
Ward number.
-
- (Object) to_hash
Hash of this Ward::Data.
Constructor Details
- (Data) initialize(data)
A new instance of Data
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ward/ward_data.rb', line 5 def initialize(data) begin data = data['objects'][0]['metadata'] @data = { :number => Integer(data['WARD']), :alderman => { :name => data['ALDERMAN'].proper_name, :office => { :address => data['ADDRESS'], :phone => data['WARD_PHONE'] }, :city_hall => { :address => data['HALL_OFFIC'], :phone => data['HALL_PHONE'] } } } rescue Exception => e @data = nil end end |
Instance Attribute Details
- (Object) data (readonly)
Returns the value of attribute data
3 4 5 |
# File 'lib/ward/ward_data.rb', line 3 def data @data end |
Instance Method Details
- (Object) alderman
Alderman Hash
33 34 35 |
# File 'lib/ward/ward_data.rb', line 33 def alderman @data[:alderman] end |
- (Object) number
Ward number
28 29 30 |
# File 'lib/ward/ward_data.rb', line 28 def number @data[:number] end |
- (Object) to_hash
Hash of this Ward::Data
38 39 40 |
# File 'lib/ward/ward_data.rb', line 38 def to_hash @data end |