Class: Dmarcurator::Parser::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dmarcurator/parser/base.rb

Overview

Base XML parser

Direct Known Subclasses

Record, Report

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml: nil, parsed_xml: nil) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
17
18
19
20
# File 'lib/dmarcurator/parser/base.rb', line 11

def initialize(xml: nil, parsed_xml: nil)
  if xml
    content = File.read(xml)
    @doc = Ox.parse(content)
  elsif parsed_xml
    @doc = parsed_xml
  else
    raise "Either :xml or :parsed_xml are required"
  end
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



9
10
11
# File 'lib/dmarcurator/parser/base.rb', line 9

def doc
  @doc
end