Class: AQI::OutcomeEvents

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ OutcomeEvents

Returns a new instance of OutcomeEvents.



4
5
6
7
8
9
10
# File 'lib/aqi/outcome_events.rb', line 4

def initialize(options)
  @event_preparer    = options.delete(:event_preparer)    || AQI::ICEventsPreparer
  @ic_events         = options.delete(:ic_events)         || []
  @outcomes_preparer = options.delete(:outcomes_preparer) || AQI::OutcomesPreparer
  @outcomes          = options.delete(:outcomes)          || []
  prepare
end

Instance Attribute Details

#event_preparerObject

Returns the value of attribute event_preparer.



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

def event_preparer
  @event_preparer
end

#ic_eventsObject

Returns the value of attribute ic_events.



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

def ic_events
  @ic_events
end

#outcomesObject

Returns the value of attribute outcomes.



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

def outcomes
  @outcomes
end

#outcomes_preparerObject

Returns the value of attribute outcomes_preparer.



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

def outcomes_preparer
  @outcomes_preparer
end

Instance Method Details

#prepareObject



12
13
14
15
# File 'lib/aqi/outcome_events.rb', line 12

def prepare
  prepare_ic_events
  prepare_outcomes
end

#prepare_ic_eventsObject



17
18
19
# File 'lib/aqi/outcome_events.rb', line 17

def prepare_ic_events
  self.ic_events = event_preparer.prepare_ic_events(self)
end

#prepare_outcomesObject



21
22
23
# File 'lib/aqi/outcome_events.rb', line 21

def prepare_outcomes
  self.outcomes = outcomes_preparer.prepare_outcomes(self)
end

#to_xmlObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/aqi/outcome_events.rb', line 25

def to_xml
  builder = Builder::XmlMarkup.new
  builder.OutcomesEvents do |oe|
    oe.ICEventSet do |ic_set|
      self.ic_events.each do |event|
        ic_set.ICEvent << event.to_xml
      end
    end
    oe.OutcomeSet do |outcome_set|
      self.outcomes.each do |outcome|
        outcome_set.Outcome << outcome.to_xml
      end
    end
  end
end