Class: Px4LogReader::Context
- Inherits:
-
Object
- Object
- Px4LogReader::Context
- Defined in:
- lib/px4_log_reader/reader.rb
Overview
Container to hold the most recent copy of each message type
Instance Attribute Summary collapse
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
-
#find_by_name(name) ⇒ Object
Query the context for the most recent copy of a message by name.
-
#find_by_type(type) ⇒ Object
Query the context for the most recent copy of a message by type.
-
#initialize ⇒ Context
constructor
A new instance of Context.
-
#set(message) ⇒ Object
Set the most recent copy of a message by type.
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
80 81 82 |
# File 'lib/px4_log_reader/reader.rb', line 80 def initialize = {} end |
Instance Attribute Details
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
78 79 80 |
# File 'lib/px4_log_reader/reader.rb', line 78 def end |
Instance Method Details
#find_by_name(name) ⇒ Object
Query the context for the most recent copy of a message by name
88 89 90 91 92 93 94 95 96 |
# File 'lib/px4_log_reader/reader.rb', line 88 def find_by_name( name ) = nil .values.each do || if .descriptor.name == name = end end return end |
#find_by_type(type) ⇒ Object
Query the context for the most recent copy of a message by type
102 103 104 |
# File 'lib/px4_log_reader/reader.rb', line 102 def find_by_type( type ) return [ type ] end |
#set(message) ⇒ Object
Set the most recent copy of a message by type. Any existing message is overwritten.
111 112 113 |
# File 'lib/px4_log_reader/reader.rb', line 111 def set( ) [ .descriptor.type ] = .dup end |