Class: GPGStatusParser::StatusMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/gpg_status_parser/status_message.rb

Constant Summary collapse

COMMAND_REGEXP =
/^\[GNUPG:\] ([^ ]+)(?: (.*))?$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status_string) ⇒ StatusMessage

Returns a new instance of StatusMessage.

Raises:



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gpg_status_parser/status_message.rb', line 17

def initialize status_string
  match = COMMAND_REGEXP.match(status_string)
  raise NotGPGStatus if match.nil?

  @status = match[1].intern
  raise InvalidStatus, @status if !STATUS_CODES.keys.include?(@status)

  expected_arg_string = GPGStatusParser::STATUS_CODES[@status]
  expected_args = GPGStatusParser::Arguments.extract_expected_arguments(expected_arg_string)
  @args = GPGStatusParser::Arguments.extract_argument_values(expected_args, match[2])
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



15
16
17
# File 'lib/gpg_status_parser/status_message.rb', line 15

def args
  @args
end

#statusObject (readonly)

Returns the value of attribute status.



15
16
17
# File 'lib/gpg_status_parser/status_message.rb', line 15

def status
  @status
end