Class: Coppertone::Qualifier
- Inherits:
-
Object
- Object
- Coppertone::Qualifier
- Defined in:
- lib/coppertone/qualifier.rb
Overview
Instances of this class represent qualifiers, as defined by the SPF specification (see section 4.6.1).
There are only 4 qualifiers permitted by the specification, so this class does not allow the creation of new instances. These fixed instances should be accessed through either the class level constants or the qualifiers class method.
Constant Summary collapse
- DEFAULT_QUALIFIER_TEXT =
'+'.freeze
- PASS =
new(DEFAULT_QUALIFIER_TEXT, Result::PASS)
- FAIL =
new('-'.freeze, Result::FAIL)
- SOFTFAIL =
new('~'.freeze, Result::SOFTFAIL)
- NEUTRAL =
new('?'.freeze, Result::NEUTRAL)
Instance Attribute Summary collapse
-
#result_code ⇒ Object
readonly
Returns the value of attribute result_code.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #default? ⇒ Boolean
-
#initialize(text, result_code) ⇒ Qualifier
constructor
A new instance of Qualifier.
- #to_s ⇒ Object
Constructor Details
#initialize(text, result_code) ⇒ Qualifier
Returns a new instance of Qualifier.
25 26 27 28 |
# File 'lib/coppertone/qualifier.rb', line 25 def initialize(text, result_code) @text = text @result_code = result_code end |
Instance Attribute Details
#result_code ⇒ Object (readonly)
Returns the value of attribute result_code.
24 25 26 |
# File 'lib/coppertone/qualifier.rb', line 24 def result_code @result_code end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
24 25 26 |
# File 'lib/coppertone/qualifier.rb', line 24 def text @text end |
Class Method Details
.default_qualifier ⇒ Object
20 21 22 |
# File 'lib/coppertone/qualifier.rb', line 20 def self.default_qualifier find_by_text(nil) end |
.find_by_text(text) ⇒ Object
15 16 17 18 |
# File 'lib/coppertone/qualifier.rb', line 15 def self.find_by_text(text) text = DEFAULT_QUALIFIER_TEXT if text.blank? @qualifier_hash[text] end |
Instance Method Details
#default? ⇒ Boolean
30 31 32 |
# File 'lib/coppertone/qualifier.rb', line 30 def default? text == DEFAULT_QUALIFIER_TEXT end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/coppertone/qualifier.rb', line 34 def to_s text end |