Class: AQI::Demographic

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Demographic

Returns a new instance of Demographic.



5
6
7
8
9
10
11
12
# File 'lib/aqi/demographic.rb', line 5

def initialize(options)
  self.date_of_birth = options[:date_of_birth]
  self.postal_code   = options[:postal_code]
  self.state         = options[:state]
  self.city          = options[:city]
  self.race          = options[:race]
  self.gender        = options[:gender]
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



3
4
5
# File 'lib/aqi/demographic.rb', line 3

def city
  @city
end

#date_of_birthObject

Returns the value of attribute date_of_birth.



3
4
5
# File 'lib/aqi/demographic.rb', line 3

def date_of_birth
  @date_of_birth
end

#genderObject

Returns the value of attribute gender.



3
4
5
# File 'lib/aqi/demographic.rb', line 3

def gender
  @gender
end

#postal_codeObject

Returns the value of attribute postal_code.



3
4
5
# File 'lib/aqi/demographic.rb', line 3

def postal_code
  @postal_code
end

#raceObject

Returns the value of attribute race.



3
4
5
# File 'lib/aqi/demographic.rb', line 3

def race
  @race
end

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/aqi/demographic.rb', line 3

def state
  @state
end

Instance Method Details

#to_xmlObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/aqi/demographic.rb', line 14

def to_xml
  builder = Builder::XmlMarkup.new
  builder.Demographic do |d|
    d.DOB(date_of_birth.strftime('%F')) if date_of_birth
    d.HomeZip(postal_code)
    d.HomeState(state)
    d.HomeCity(city)
    d.Race(race || 'UNKNOWN')
    d.Gender(gender)
  end
end