Class: ActionCommand::LogMessage
- Inherits:
-
Object
- Object
- ActionCommand::LogMessage
- Defined in:
- lib/action_command/log_parser.rb
Overview
A single entry in the action command log
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#key ⇒ Object
Returns the value of attribute key.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
Instance Method Summary collapse
-
#command?(cmd) ⇒ Boolean
True if the cmds equal (tolerant of being passed a class).
-
#depth ⇒ Object
The number of parents the current command has.
- #key?(key) ⇒ Boolean
-
#kind?(kind) ⇒ Boolean
True if the kinds equal (tolerant of string/symbol mismatch).
-
#line ⇒ Object
The line that was used to create this message.
-
#match_message?(msg) ⇒ Boolean
@ return true if msgs equal.
-
#populate(line, msg) ⇒ Object
Create a new log message.
-
#root? ⇒ Boolean
True if this command is the root command.
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd.
8 9 10 |
# File 'lib/action_command/log_parser.rb', line 8 def cmd @cmd end |
#key ⇒ Object
Returns the value of attribute key.
8 9 10 |
# File 'lib/action_command/log_parser.rb', line 8 def key @key end |
#kind ⇒ Object
Returns the value of attribute kind.
8 9 10 |
# File 'lib/action_command/log_parser.rb', line 8 def kind @kind end |
#msg ⇒ Object
Returns the value of attribute msg.
8 9 10 |
# File 'lib/action_command/log_parser.rb', line 8 def msg @msg end |
#sequence ⇒ Object
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).
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 |
#depth ⇒ Object
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
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).
41 42 43 44 |
# File 'lib/action_command/log_parser.rb', line 41 def kind?(kind) kind = kind.to_s return @kind == kind end |
#line ⇒ Object
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
53 54 55 56 57 58 59 60 61 |
# File 'lib/action_command/log_parser.rb', line 53 def (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.
27 28 29 |
# File 'lib/action_command/log_parser.rb', line 27 def root? return @depth == 0 end |