class DKIM::Query::Key
Represents an individual DKIM
signing key.
Attributes
`t=` tag.
@return [:y, :s, String, nil]
`g=` tag.
@return [String, nil]
`g=` tag.
@return [String, nil]
`h=` tag.
@return [:sha1, :sha256, Array<:sha1, :sha256, String>, nil]
`h=` tag.
@return [:sha1, :sha256, Array<:sha1, :sha256, String>, nil]
`k=` tag.
@return [:rsa, String]
`k=` tag.
@return [:rsa, String]
`n=` tag.
@return [String, nil]
`n=` tag.
@return [String, nil]
`p=` tag.
@return [String, nil]
`p=` tag.
@return [String, nil]
`s=` tag.
@return [:email, :*, String, Array<:email, :*, String>, nil]
`s=` tag.
@return [:email, :*, String, Array<:email, :*, String>, nil]
`t=` tag.
@return [:y, :s, String, nil]
DKIM
version.
@return [:DKIM1]
DKIM
version.
@return [:DKIM1]
Public Class Methods
Initialize the key.
@param [Hash{Symbol => Symbol,String}] tags
Tags for the key.
@option tags [Symbol] :v
@option tags [Symbol] :g
@option tags [Symbol] :h
@option tags [Symbol] :k
@option tags [Symbol] :n
@option tags [Symbol] :p
@option tags [Symbol] :s
@option tags [Symbol] :t
# File lib/dkim/query/key.rb, line 82 def initialize(tags={}) @v, @g, @h, @k, @n, @p, @s, @t = tags.values_at(:v,:g,:h,:k,:n,:p,:s,:t) end
@param [String] record
The DKIM key record.
@return [Key, MalformedKey]
The parsed key. If the key could not be parsed, a {MalformedKey} will be returned.
# File lib/dkim/query/key.rb, line 114 def self.parse(record) begin parse!(record) rescue Parslet::ParseFailed => error MalformedKey.new(record,error.cause) end end
@param [String] record
The DKIM key record.
@return [Key]
The new key.
@raise [InvalidKey]
Could not parse the DKIM Key record.
# File lib/dkim/query/key.rb, line 98 def self.parse!(record) new(Parser.parse(record)) rescue Parslet::ParseFailed => error raise(InvalidKey.new(error.message,error.cause)) end
Public Instance Methods
Converts the key to a Hash.
@return [Hash{:v,:g,:h,:k,:n,:p,:s,:t => Object}]
# File lib/dkim/query/key.rb, line 127 def to_hash { v: @v, g: @g, h: @h, k: @k, n: @n, p: @p, s: @s, t: @t } end
Converts the key back into a DKIM
String.
@return [String]
# File lib/dkim/query/key.rb, line 145 def to_s tags = [] tags << "v=#{@v}" if @v tags << "g=#{@g}" if @g tags << "h=#{@h}" if @h tags << "k=#{@k}" if @k tags << "p=#{@p}" if @p tags << "s=#{@s}" if @s tags << "t=#{@t}" if @t tags << "n=#{@n}" if @n return tags.join('; ') end