class DMARC::Uri

Represents a DMARC URI.

@see tools.ietf.org/html/rfc7489#section-6.2

@since 0.5.0

Attributes

size[R]

The optional maximum-size.

@return [Integer, nil]

unit[R]

The optional unit.

@return [:k, :m, :g, :t, nil]

uri[R]

The ‘mailto:` URI.

@return [URI::MailTo]

Public Class Methods

new(uri,size=nil,unit=nil) click to toggle source

Initializes the DMARC URI.

@param [URI::MailTo] uri

The `mailto:` URI.

@param [Integer] size

The optional maximum-size.

@param [:k, :m, :g, :t] unit

The optional size unit.
# File lib/dmarc/uri.rb, line 38
def initialize(uri,size=nil,unit=nil)
  @uri = uri

  @size = size
  @unit = unit
end

Public Instance Methods

==(other) click to toggle source

Determines if the DMARC URI matches the other.

@param [Object] other

the other DMARC URI to compare against.

@return [Boolean]

# File lib/dmarc/uri.rb, line 71
def ==(other)
  (self.class == other.class) &&
  (@uri == other.uri) &&
  (@size == other.size) &&
  (@unit == other.unit)
end
size?() click to toggle source

Determines if a maximum-size was set.

@return [Boolean]

# File lib/dmarc/uri.rb, line 50
def size?
  !@size.nil?
end
to_s() click to toggle source

Converts the DMARC URI back into a String.

@return [String]

# File lib/dmarc/uri.rb, line 83
def to_s
  str = @uri.to_s

  if (@size || @unit)
    str << "!"
    str << "#{@size}" if @size
    str << "#{@unit}" if @unit
  end

  return str
end
unit?() click to toggle source

Determines if a size unit was set.

@return [Boolean]

# File lib/dmarc/uri.rb, line 59
def unit?
  !@unit.nil?
end

Protected Instance Methods

method_missing(name,*arguments,&block) click to toggle source

Pass all missing methods to {#uri}.

# File lib/dmarc/uri.rb, line 100
def method_missing(name,*arguments,&block)
  @uri.send(name,*arguments,&block)
end