Class: ActionCommand::LogMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/action_command/log_parser.rb

Overview

A single entry in the action command log

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cmdObject

Returns the value of attribute cmd.



8
9
10
# File 'lib/action_command/log_parser.rb', line 8

def cmd
  @cmd
end

#keyObject

Returns the value of attribute key.



8
9
10
# File 'lib/action_command/log_parser.rb', line 8

def key
  @key
end

#kindObject

Returns the value of attribute kind.



8
9
10
# File 'lib/action_command/log_parser.rb', line 8

def kind
  @kind
end

#msgObject

Returns the value of attribute msg.



8
9
10
# File 'lib/action_command/log_parser.rb', line 8

def msg
  @msg
end

#sequenceObject

Returns the value of attribute sequence.



8
9
10
# File 'lib/action_command/log_parser.rb', line 8

def sequence
  @sequence
end

Instance Method Details

#command?(cmd) ⇒ Boolean

Returns true if the cmds equal (tolerant of being passed a class).

Returns:

  • (Boolean)

    true if the cmds equal (tolerant of being passed a class)



47
48
49
50
# File 'lib/action_command/log_parser.rb', line 47

def command?(cmd)
  cmd = cmd.name if cmd.is_a? Class
  return @cmd == cmd
end

#depthObject

Returns the number of parents the current command has.

Returns:

  • the number of parents the current command has



22
23
24
# File 'lib/action_command/log_parser.rb', line 22

def depth
  return @depth
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/action_command/log_parser.rb', line 36

def key?(key)
  return @key == key
end

#kind?(kind) ⇒ Boolean

Returns true if the kinds equal (tolerant of string/symbol mismatch).

Returns:

  • (Boolean)

    true if the kinds equal (tolerant of string/symbol mismatch)



41
42
43
44
# File 'lib/action_command/log_parser.rb', line 41

def kind?(kind)
  kind = kind.to_s
  return @kind == kind
end

#lineObject

Returns the line that was used to create this message.

Returns:

  • the line that was used to create this message.



32
33
34
# File 'lib/action_command/log_parser.rb', line 32

def line
  return @line
end

#match_message?(msg) ⇒ Boolean

@ return true if msgs equal

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
61
# File 'lib/action_command/log_parser.rb', line 53

def match_message?(msg)
  return @msg == msg unless msg.is_a? Hash
  msg.each do |k, v|
    k = k.to_s if k.is_a? Symbol
    return false unless @msg.key?(k)
    return false unless @msg[k] == v
  end
  return true
end

#populate(line, msg) ⇒ Object

Create a new log message



11
12
13
14
15
16
17
18
19
# File 'lib/action_command/log_parser.rb', line 11

def populate(line, msg)
  @line = line
  @sequence = msg['sequence']
  @depth = msg['depth']
  @cmd = msg['cmd']
  @kind = msg['kind']
  @msg = msg['msg']
  @key = msg['key']
end

#root?Boolean

Returns true if this command is the root command.

Returns:

  • (Boolean)

    true if this command is the root command



27
28
29
# File 'lib/action_command/log_parser.rb', line 27

def root?
  return @depth == 0
end