Class: TCD::LookupTables
- Inherits:
-
Object
- Object
- TCD::LookupTables
- Defined in:
- lib/tcd/lookup_tables.rb
Overview
Reader for TCD lookup tables (fixed-size string arrays).
TCD v2 stores string tables in this order after the 4-byte checksum:
-
Level units (level_unit_types × level_unit_size) - exact count
-
Direction units (dir_unit_types × dir_unit_size) - exact count
-
Restrictions (max_restriction_types × restriction_size) - reads until “__END__”
- v1 only: Pedigrees - skipped in v2
-
Timezones (max_tzfiles × tzfile_size) - reads until “__END__”
-
Countries (max_countries × country_size) - reads until “__END__”
-
Datums (max_datum_types × datum_size) - reads until “__END__”
- v2 only: Legalese (max_legaleses × legalese_size) - reads until “__END__”
-
Constituent names (constituents × constituent_size) - exact count
-
Constituent speeds (bit-packed)
-
Equilibrium arguments (bit-packed)
-
Node factors (bit-packed)
-
Station records (bit-packed)
Instance Attribute Summary collapse
-
#constituent_data_offset ⇒ Object
readonly
Positions tracked for the reader.
-
#constituents ⇒ Object
readonly
Returns the value of attribute constituents.
-
#countries ⇒ Object
readonly
Returns the value of attribute countries.
-
#datums ⇒ Object
readonly
Returns the value of attribute datums.
-
#direction_units ⇒ Object
readonly
Returns the value of attribute direction_units.
-
#legalese ⇒ Object
readonly
Returns the value of attribute legalese.
-
#level_units ⇒ Object
readonly
Returns the value of attribute level_units.
-
#restrictions ⇒ Object
readonly
Returns the value of attribute restrictions.
-
#station_records_offset ⇒ Object
readonly
Where station records start.
-
#timezones ⇒ Object
readonly
Returns the value of attribute timezones.
Instance Method Summary collapse
- #constituent(idx) ⇒ Object
- #country(idx) ⇒ Object
- #datum(idx) ⇒ Object
- #direction_unit(idx) ⇒ Object
-
#initialize(io, header) ⇒ LookupTables
constructor
A new instance of LookupTables.
- #legalese_text(idx) ⇒ Object
-
#level_unit(idx) ⇒ Object
Lookup by index with bounds checking.
- #restriction(idx) ⇒ Object
-
#timezone(idx) ⇒ Object
Timezone strings in TCD files have a leading colon (e.g., “:America/New_York”) Strip it to return standard IANA timezone names.
Constructor Details
#initialize(io, header) ⇒ LookupTables
Returns a new instance of LookupTables.
30 31 32 33 34 |
# File 'lib/tcd/lookup_tables.rb', line 30 def initialize(io, header) @io = io @header = header load_tables end |
Instance Attribute Details
#constituent_data_offset ⇒ Object (readonly)
Positions tracked for the reader
27 28 29 |
# File 'lib/tcd/lookup_tables.rb', line 27 def constituent_data_offset @constituent_data_offset end |
#constituents ⇒ Object (readonly)
Returns the value of attribute constituents.
23 24 25 |
# File 'lib/tcd/lookup_tables.rb', line 23 def constituents @constituents end |
#countries ⇒ Object (readonly)
Returns the value of attribute countries.
24 25 26 |
# File 'lib/tcd/lookup_tables.rb', line 24 def countries @countries end |
#datums ⇒ Object (readonly)
Returns the value of attribute datums.
23 24 25 |
# File 'lib/tcd/lookup_tables.rb', line 23 def datums @datums end |
#direction_units ⇒ Object (readonly)
Returns the value of attribute direction_units.
22 23 24 |
# File 'lib/tcd/lookup_tables.rb', line 22 def direction_units @direction_units end |
#legalese ⇒ Object (readonly)
Returns the value of attribute legalese.
23 24 25 |
# File 'lib/tcd/lookup_tables.rb', line 23 def legalese @legalese end |
#level_units ⇒ Object (readonly)
Returns the value of attribute level_units.
22 23 24 |
# File 'lib/tcd/lookup_tables.rb', line 22 def level_units @level_units end |
#restrictions ⇒ Object (readonly)
Returns the value of attribute restrictions.
22 23 24 |
# File 'lib/tcd/lookup_tables.rb', line 22 def restrictions @restrictions end |
#station_records_offset ⇒ Object (readonly)
Where station records start
28 29 30 |
# File 'lib/tcd/lookup_tables.rb', line 28 def station_records_offset @station_records_offset end |
#timezones ⇒ Object (readonly)
Returns the value of attribute timezones.
24 25 26 |
# File 'lib/tcd/lookup_tables.rb', line 24 def timezones @timezones end |
Instance Method Details
#constituent(idx) ⇒ Object
42 |
# File 'lib/tcd/lookup_tables.rb', line 42 def constituent(idx); safe_lookup(@constituents, idx); end |
#country(idx) ⇒ Object
43 |
# File 'lib/tcd/lookup_tables.rb', line 43 def country(idx); safe_lookup(@countries, idx); end |
#datum(idx) ⇒ Object
41 |
# File 'lib/tcd/lookup_tables.rb', line 41 def datum(idx); safe_lookup(@datums, idx); end |
#direction_unit(idx) ⇒ Object
38 |
# File 'lib/tcd/lookup_tables.rb', line 38 def direction_unit(idx); safe_lookup(@direction_units, idx); end |
#legalese_text(idx) ⇒ Object
40 |
# File 'lib/tcd/lookup_tables.rb', line 40 def legalese_text(idx); safe_lookup(@legalese, idx); end |
#level_unit(idx) ⇒ Object
Lookup by index with bounds checking
37 |
# File 'lib/tcd/lookup_tables.rb', line 37 def level_unit(idx); safe_lookup(@level_units, idx); end |
#restriction(idx) ⇒ Object
39 |
# File 'lib/tcd/lookup_tables.rb', line 39 def restriction(idx); safe_lookup(@restrictions, idx); end |
#timezone(idx) ⇒ Object
Timezone strings in TCD files have a leading colon (e.g., “:America/New_York”) Strip it to return standard IANA timezone names
47 48 49 50 |
# File 'lib/tcd/lookup_tables.rb', line 47 def timezone(idx) tz = safe_lookup(@timezones, idx) tz&.sub(/^:/, '') end |