Class: F4R::Registry
- Inherits:
-
Object
- Object
- F4R::Registry
- Defined in:
- lib/f4r.rb
Overview
Stores records and meta data for encoding and decoding
Instance Attribute Summary collapse
-
#definitions ⇒ Array<Hash>
Definitions for all records.
-
#header ⇒ BinData::RecordHeader
readonly
Main file header.
-
#records ⇒ Hash
Storage for all records including their meta data.
Instance Method Summary collapse
-
#add(record, local_message_number) ⇒ Object
Add record to @records [Array<Hash>].
-
#definition(record) ⇒ Hash
Helper method to find the associated definitions with an specific record.
-
#initialize(header) ⇒ Registry
constructor
A new instance of Registry.
Constructor Details
#initialize(header) ⇒ Registry
Returns a new instance of Registry.
1242 1243 1244 1245 1246 |
# File 'lib/f4r.rb', line 1242 def initialize(header) @header = header @records = [] @definitions = [] end |
Instance Attribute Details
#definitions ⇒ Array<Hash>
Definitions for all records
1240 1241 1242 |
# File 'lib/f4r.rb', line 1240 def definitions @definitions end |
#header ⇒ BinData::RecordHeader (readonly)
Main file header
1226 1227 1228 |
# File 'lib/f4r.rb', line 1226 def header @header end |
#records ⇒ Hash
Storage for all records including their meta data
1233 1234 1235 |
# File 'lib/f4r.rb', line 1233 def records @records end |
Instance Method Details
#add(record, local_message_number) ⇒ Object
Add record to @records [Array<Hash>]
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 |
# File 'lib/f4r.rb', line 1254 def add(record, ) @records << { index: @records.size, message_name: record.[:name], message_number: record.[:number], message_source: record.[:source], local_message_number: , fields: record.fields } end |
#definition(record) ⇒ Hash
Helper method to find the associated definitions with an specific record
1271 1272 1273 1274 1275 1276 |
# File 'lib/f4r.rb', line 1271 def definition(record) definitions.find do |d| d[:local_message_number] == record[:local_message_number] && d[:message_name] == record[:message_name] end end |