Class: DMARC::Record

Inherits:
Struct
  • Object
show all
Defined in:
lib/dmarc/record.rb

Constant Summary collapse

DEFAULTS =
{
  adkim: 'r',
  aspf:  'r',
  fo:    '0',
  pct:   100,
  rf:    'afrf',
  ri:    86400,
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Record

Returns a new instance of Record.



22
23
24
25
26
27
28
# File 'lib/dmarc/record.rb', line 22

def initialize(attributes={})
  attributes.merge(DEFAULTS).each_pair do |k,v|
    self[k] = v
  end

  self.sp ||= p
end

Instance Attribute Details

#adkimObject

Returns the value of attribute adkim

Returns:

  • (Object)

    the current value of adkim



5
6
7
# File 'lib/dmarc/record.rb', line 5

def adkim
  @adkim
end

#aspfObject

Returns the value of attribute aspf

Returns:

  • (Object)

    the current value of aspf



5
6
7
# File 'lib/dmarc/record.rb', line 5

def aspf
  @aspf
end

#foObject

Returns the value of attribute fo

Returns:

  • (Object)

    the current value of fo



5
6
7
# File 'lib/dmarc/record.rb', line 5

def fo
  @fo
end

#pObject

Returns the value of attribute p

Returns:

  • (Object)

    the current value of p



5
6
7
# File 'lib/dmarc/record.rb', line 5

def p
  @p
end

#pctObject

Returns the value of attribute pct

Returns:

  • (Object)

    the current value of pct



5
6
7
# File 'lib/dmarc/record.rb', line 5

def pct
  @pct
end

#rfObject

Returns the value of attribute rf

Returns:

  • (Object)

    the current value of rf



5
6
7
# File 'lib/dmarc/record.rb', line 5

def rf
  @rf
end

#riObject

Returns the value of attribute ri

Returns:

  • (Object)

    the current value of ri



5
6
7
# File 'lib/dmarc/record.rb', line 5

def ri
  @ri
end

#ruaObject

Returns the value of attribute rua

Returns:

  • (Object)

    the current value of rua



5
6
7
# File 'lib/dmarc/record.rb', line 5

def rua
  @rua
end

#rufObject

Returns the value of attribute ruf

Returns:

  • (Object)

    the current value of ruf



5
6
7
# File 'lib/dmarc/record.rb', line 5

def ruf
  @ruf
end

#spObject

Returns the value of attribute sp

Returns:

  • (Object)

    the current value of sp



5
6
7
# File 'lib/dmarc/record.rb', line 5

def sp
  @sp
end

#vObject

Returns the value of attribute v

Returns:

  • (Object)

    the current value of v



5
6
7
# File 'lib/dmarc/record.rb', line 5

def v
  @v
end

Class Method Details

.from_txt(rec) ⇒ Object



7
8
9
10
11
# File 'lib/dmarc/record.rb', line 7

def self.from_txt(rec)
  new(Parser.new.parse(rec))
rescue Parslet::ParseFailed
  raise InvalidRecord
end