Class: Coppertone::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/coppertone/result.rb

Overview

The result of an SPF query. Includes a code, which indicates the overall result (pass, fail, softfail, etc.). For different results it may include the mechanism which led to the result, an error message, and/or an explanation string.

Constant Summary collapse

NONE =
:none
PASS =
:pass
FAIL =
:fail
SOFTFAIL =
:softfail
NEUTRAL =
:neutral
TEMPERROR =
:temperror
PERMERROR =
:permerror

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, mechanism = nil) ⇒ Result



20
21
22
23
# File 'lib/coppertone/result.rb', line 20

def initialize(code, mechanism = nil)
  @code = code
  @mechanism = mechanism
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



17
18
19
# File 'lib/coppertone/result.rb', line 17

def code
  @code
end

#explanationObject

Returns the value of attribute explanation.



18
19
20
# File 'lib/coppertone/result.rb', line 18

def explanation
  @explanation
end

#identityObject

Returns the value of attribute identity.



18
19
20
# File 'lib/coppertone/result.rb', line 18

def identity
  @identity
end

#mechanismObject (readonly)

Returns the value of attribute mechanism.



17
18
19
# File 'lib/coppertone/result.rb', line 17

def mechanism
  @mechanism
end

#problemObject

Returns the value of attribute problem.



18
19
20
# File 'lib/coppertone/result.rb', line 18

def problem
  @problem
end

Class Method Details

.from_directive(directive) ⇒ Object



25
26
27
# File 'lib/coppertone/result.rb', line 25

def self.from_directive(directive)
  new(directive.qualifier.result_code, directive.mechanism)
end

.neutralObject



45
46
47
# File 'lib/coppertone/result.rb', line 45

def self.neutral
  Result.new(:neutral)
end

.noneObject



41
42
43
# File 'lib/coppertone/result.rb', line 41

def self.none
  Result.new(:none)
end

.permerror(message) ⇒ Object



29
30
31
32
33
# File 'lib/coppertone/result.rb', line 29

def self.permerror(message)
  r = Result.new(:permerror)
  r.problem = message
  r
end

.temperror(message) ⇒ Object



35
36
37
38
39
# File 'lib/coppertone/result.rb', line 35

def self.temperror(message)
  r = Result.new(:temperror)
  r.problem = message
  r
end