class RubyGPG2::StatusLines::ImportOK

Constants

REASONS

Attributes

key_fingerprint[R]
raw[R]
reasons[R]

Public Class Methods

new(opts) click to toggle source
# File lib/ruby_gpg2/status_lines/import_ok.rb, line 25
def initialize(opts)
  @raw = opts[:raw]
  @reasons = opts[:reasons]
  @key_fingerprint = opts[:key_fingerprint]
end
parse(line) click to toggle source
# File lib/ruby_gpg2/status_lines/import_ok.rb, line 12
def self.parse(line)
  match = line.match(/^\[GNUPG:\] IMPORT_OK (\d+) (.*)$/)
  new(
      raw: line,
      reasons: reasons(match[1]),
      key_fingerprint: match[2])
end

Private Class Methods

reasons(value) click to toggle source
# File lib/ruby_gpg2/status_lines/import_ok.rb, line 51
def self.reasons(value)
  value = value.to_i
  if value == 0
    [:no_change]
  else
    REASONS.inject([]) do |r, entry|
      (value & entry[0]) > 0 ?
          (r << entry[1]) :
          r
    end
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/ruby_gpg2/status_lines/import_ok.rb, line 35
def ==(other)
  other.class == self.class && other.state == state
end
type() click to toggle source
# File lib/ruby_gpg2/status_lines/import_ok.rb, line 31
def type
  :import_ok
end

Protected Instance Methods

state() click to toggle source
# File lib/ruby_gpg2/status_lines/import_ok.rb, line 41
def state
  [
      @raw,
      @reasons,
      @key_fingerprint
  ]
end