Class: AQI::CPT
- Inherits:
-
Object
- Object
- AQI::CPT
- Defined in:
- lib/aqi/cpt.rb
Instance Attribute Summary collapse
-
#modifier ⇒ Object
Returns the value of attribute modifier.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(options) ⇒ CPT
constructor
A new instance of CPT.
- #to_xml ⇒ Object
- #validate_value(value) ⇒ Object
Constructor Details
#initialize(options) ⇒ CPT
Returns a new instance of CPT.
5 6 7 8 9 |
# File 'lib/aqi/cpt.rb', line 5 def initialize() self.rank = [:rank] self.value = validate_value([:value]) self.modifier = [:modifier] end |
Instance Attribute Details
#modifier ⇒ Object
Returns the value of attribute modifier.
3 4 5 |
# File 'lib/aqi/cpt.rb', line 3 def modifier @modifier end |
#rank ⇒ Object
Returns the value of attribute rank.
3 4 5 |
# File 'lib/aqi/cpt.rb', line 3 def rank @rank end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/aqi/cpt.rb', line 3 def value @value end |
Instance Method Details
#to_xml ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aqi/cpt.rb', line 15 def to_xml return '' unless value builder = Builder::XmlMarkup.new builder.CPT do |cpt| cpt.CPTRank(rank) if rank cpt.CPTValue(value) cpt.CPTModifier(modifier) if modifier end end |
#validate_value(value) ⇒ Object
11 12 13 |
# File 'lib/aqi/cpt.rb', line 11 def validate_value(value) value =~ /\d\d\d\d[\w\d]/ ? value : nil end |