Class: AQI::ICEvent

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ICEvent

Returns a new instance of ICEvent.



10
11
12
13
14
15
16
17
18
# File 'lib/aqi/ic_event.rb', line 10

def initialize(options)
  self.event_time_date = options.delete(:event_time_date)
  self.category        = options.delete(:category)
  self.severity        = options.delete(:severity)
  self.name            = options.delete(:name)
  self.description     = options.delete(:description)
  self.value           = options.delete(:value)
  self.notes           = options.delete(:notes)
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



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

def category
  @category
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#event_time_dateObject

Returns the value of attribute event_time_date.



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

def event_time_date
  @event_time_date
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#notesObject

Returns the value of attribute notes.



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

def notes
  @notes
end

#severityObject

Returns the value of attribute severity.



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

def severity
  @severity
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.categoriesObject



5
6
7
8
# File 'lib/aqi/ic_event.rb', line 5

def self.categories
  ["MEDICAL DEVICE/EQUIPMENT","MEDICATION", "INFRASTRUCTURE/SYSTEM", "ASSESSMENT/DOCUMENTATION",
    "RESPIRATORY/AIRWAY", "CARDIOVASCULAR", "PROCEDURE RELATED", "OTHER", "UNKNOWN" ]
end

Instance Method Details

#to_xmlObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/aqi/ic_event.rb', line 24

def to_xml
  builder = Builder::XmlMarkup.new
  builder.ICEvent do |ice|
    ice.ICEventTimeDate(event_time_date.strftime('%FT%T')) if event_time_date
    ice.ICCategory(validate_category(category))
    ice.ICSeverity(severity)
    ice.ICName(name)
    ice.ICDesciption(description)
    ice.ICValue(value)
    ice.ICNotes(notes)
  end
end

#validate_category(value) ⇒ Object



20
21
22
# File 'lib/aqi/ic_event.rb', line 20

def validate_category(value)
  self.class.categories.include?(value) ? value : "UNKNOWN"
end