Class: TCD::Header
- Inherits:
-
Object
- Object
- TCD::Header
- Defined in:
- lib/tcd/header.rb
Overview
Parser for TCD ASCII header section. The header contains [KEY] = VALUE pairs defining all encoding parameters.
Constant Summary collapse
- REQUIRED_KEYS =
%i[ header_size number_of_records constituents start_year number_of_years ].freeze
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Access header parameters by symbol key.
- #amplitude_bits ⇒ Object
- #amplitude_scale ⇒ Object
- #confidence_value_bits ⇒ Object
- #constituent_bits ⇒ Object
- #constituent_size ⇒ Object
- #constituents ⇒ Object
- #countries ⇒ Object
- #country_bits ⇒ Object
- #country_size ⇒ Object
- #date_bits ⇒ Object
- #datum_bits ⇒ Object
- #datum_offset_bits ⇒ Object
- #datum_offset_scale ⇒ Object
- #datum_size ⇒ Object
- #datum_types ⇒ Object
- #direction_bits ⇒ Object
- #direction_unit_bits ⇒ Object
- #direction_unit_size ⇒ Object
- #direction_unit_types ⇒ Object
- #end_of_file ⇒ Object
- #epoch_bits ⇒ Object
- #epoch_scale ⇒ Object
- #equilibrium_bits ⇒ Object
- #equilibrium_offset ⇒ Object
- #equilibrium_scale ⇒ Object
-
#header_size ⇒ Object
Convenience accessors for commonly used parameters.
-
#initialize(io) ⇒ Header
constructor
A new instance of Header.
-
#key?(key) ⇒ Boolean
Check if key exists.
-
#keys ⇒ Object
All parameter keys.
- #last_modified ⇒ Object
- #latitude_bits ⇒ Object
- #latitude_scale ⇒ Object
- #legalese_bits ⇒ Object
- #legalese_size ⇒ Object
- #legalese_types ⇒ Object
- #level_add_bits ⇒ Object
- #level_add_scale ⇒ Object
- #level_multiply_bits ⇒ Object
- #level_multiply_scale ⇒ Object
-
#level_unit_bits ⇒ Object
Lookup table parameters.
- #level_unit_size ⇒ Object
- #level_unit_types ⇒ Object
- #longitude_bits ⇒ Object
- #longitude_scale ⇒ Object
- #major_rev ⇒ Object
- #minor_rev ⇒ Object
- #months_on_station_bits ⇒ Object
- #node_bits ⇒ Object
- #node_offset ⇒ Object
- #node_scale ⇒ Object
- #number_of_records ⇒ Object
- #number_of_years ⇒ Object
- #record_size_bits ⇒ Object
-
#record_type_bits ⇒ Object
Record field parameters.
- #restriction_bits ⇒ Object
- #restriction_size ⇒ Object
- #restriction_types ⇒ Object
-
#speed_bits ⇒ Object
Bit field parameters.
- #speed_offset ⇒ Object
- #speed_scale ⇒ Object
- #start_year ⇒ Object
- #station_bits ⇒ Object
- #time_bits ⇒ Object
- #tzfile_bits ⇒ Object
- #tzfile_size ⇒ Object
- #tzfiles ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(io) ⇒ Header
Returns a new instance of Header.
14 15 16 17 18 |
# File 'lib/tcd/header.rb', line 14 def initialize(io) @params = {} parse(io) validate! end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
12 13 14 |
# File 'lib/tcd/header.rb', line 12 def params @params end |
Instance Method Details
#[](key) ⇒ Object
Access header parameters by symbol key
21 22 23 |
# File 'lib/tcd/header.rb', line 21 def [](key) @params[key] end |
#amplitude_bits ⇒ Object
57 |
# File 'lib/tcd/header.rb', line 57 def amplitude_bits; @params[:amplitude_bits]; end |
#amplitude_scale ⇒ Object
58 |
# File 'lib/tcd/header.rb', line 58 def amplitude_scale; @params[:amplitude_scale]; end |
#confidence_value_bits ⇒ Object
74 |
# File 'lib/tcd/header.rb', line 74 def confidence_value_bits; @params[:confidence_value_bits]; end |
#constituent_bits ⇒ Object
98 |
# File 'lib/tcd/header.rb', line 98 def constituent_bits; @params[:constituent_bits]; end |
#constituent_size ⇒ Object
99 |
# File 'lib/tcd/header.rb', line 99 def constituent_size; @params[:constituent_size]; end |
#constituents ⇒ Object
38 |
# File 'lib/tcd/header.rb', line 38 def constituents; @params[:constituents]; end |
#countries ⇒ Object
104 |
# File 'lib/tcd/header.rb', line 104 def countries; @params[:countries]; end |
#country_bits ⇒ Object
103 |
# File 'lib/tcd/header.rb', line 103 def country_bits; @params[:country_bits]; end |
#country_size ⇒ Object
105 |
# File 'lib/tcd/header.rb', line 105 def country_size; @params[:country_size]; end |
#date_bits ⇒ Object
72 |
# File 'lib/tcd/header.rb', line 72 def date_bits; @params[:date_bits]; end |
#datum_bits ⇒ Object
92 |
# File 'lib/tcd/header.rb', line 92 def datum_bits; @params[:datum_bits]; end |
#datum_offset_bits ⇒ Object
70 |
# File 'lib/tcd/header.rb', line 70 def datum_offset_bits; @params[:datum_offset_bits]; end |
#datum_offset_scale ⇒ Object
71 |
# File 'lib/tcd/header.rb', line 71 def datum_offset_scale; @params[:datum_offset_scale]; end |
#datum_size ⇒ Object
94 |
# File 'lib/tcd/header.rb', line 94 def datum_size; @params[:datum_size]; end |
#datum_types ⇒ Object
93 |
# File 'lib/tcd/header.rb', line 93 def datum_types; @params[:datum_types]; end |
#direction_bits ⇒ Object
80 |
# File 'lib/tcd/header.rb', line 80 def direction_bits; @params[:direction_bits]; end |
#direction_unit_bits ⇒ Object
86 |
# File 'lib/tcd/header.rb', line 86 def direction_unit_bits; @params[:direction_unit_bits]; end |
#direction_unit_size ⇒ Object
88 |
# File 'lib/tcd/header.rb', line 88 def direction_unit_size; @params[:direction_unit_size]; end |
#direction_unit_types ⇒ Object
87 |
# File 'lib/tcd/header.rb', line 87 def direction_unit_types; @params[:direction_unit_types]; end |
#end_of_file ⇒ Object
45 |
# File 'lib/tcd/header.rb', line 45 def end_of_file; @params[:end_of_file]; end |
#epoch_bits ⇒ Object
59 |
# File 'lib/tcd/header.rb', line 59 def epoch_bits; @params[:epoch_bits]; end |
#epoch_scale ⇒ Object
60 |
# File 'lib/tcd/header.rb', line 60 def epoch_scale; @params[:epoch_scale]; end |
#equilibrium_bits ⇒ Object
51 |
# File 'lib/tcd/header.rb', line 51 def equilibrium_bits; @params[:equilibrium_bits]; end |
#equilibrium_offset ⇒ Object
53 |
# File 'lib/tcd/header.rb', line 53 def equilibrium_offset; @params[:equilibrium_offset]; end |
#equilibrium_scale ⇒ Object
52 |
# File 'lib/tcd/header.rb', line 52 def equilibrium_scale; @params[:equilibrium_scale]; end |
#header_size ⇒ Object
Convenience accessors for commonly used parameters
36 |
# File 'lib/tcd/header.rb', line 36 def header_size; @params[:header_size]; end |
#key?(key) ⇒ Boolean
Check if key exists
26 27 28 |
# File 'lib/tcd/header.rb', line 26 def key?(key) @params.key?(key) end |
#keys ⇒ Object
All parameter keys
31 32 33 |
# File 'lib/tcd/header.rb', line 31 def keys @params.keys end |
#last_modified ⇒ Object
44 |
# File 'lib/tcd/header.rb', line 44 def last_modified; @params[:last_modified]; end |
#latitude_bits ⇒ Object
64 |
# File 'lib/tcd/header.rb', line 64 def latitude_bits; @params[:latitude_bits]; end |
#latitude_scale ⇒ Object
65 |
# File 'lib/tcd/header.rb', line 65 def latitude_scale; @params[:latitude_scale]; end |
#legalese_bits ⇒ Object
95 |
# File 'lib/tcd/header.rb', line 95 def legalese_bits; @params[:legalese_bits]; end |
#legalese_size ⇒ Object
97 |
# File 'lib/tcd/header.rb', line 97 def legalese_size; @params[:legalese_size]; end |
#legalese_types ⇒ Object
96 |
# File 'lib/tcd/header.rb', line 96 def legalese_types; @params[:legalese_types]; end |
#level_add_bits ⇒ Object
76 |
# File 'lib/tcd/header.rb', line 76 def level_add_bits; @params[:level_add_bits]; end |
#level_add_scale ⇒ Object
77 |
# File 'lib/tcd/header.rb', line 77 def level_add_scale; @params[:level_add_scale]; end |
#level_multiply_bits ⇒ Object
78 |
# File 'lib/tcd/header.rb', line 78 def level_multiply_bits; @params[:level_multiply_bits]; end |
#level_multiply_scale ⇒ Object
79 |
# File 'lib/tcd/header.rb', line 79 def level_multiply_scale; @params[:level_multiply_scale]; end |
#level_unit_bits ⇒ Object
Lookup table parameters
83 |
# File 'lib/tcd/header.rb', line 83 def level_unit_bits; @params[:level_unit_bits]; end |
#level_unit_size ⇒ Object
85 |
# File 'lib/tcd/header.rb', line 85 def level_unit_size; @params[:level_unit_size]; end |
#level_unit_types ⇒ Object
84 |
# File 'lib/tcd/header.rb', line 84 def level_unit_types; @params[:level_unit_types]; end |
#longitude_bits ⇒ Object
66 |
# File 'lib/tcd/header.rb', line 66 def longitude_bits; @params[:longitude_bits]; end |
#longitude_scale ⇒ Object
67 |
# File 'lib/tcd/header.rb', line 67 def longitude_scale; @params[:longitude_scale]; end |
#major_rev ⇒ Object
42 |
# File 'lib/tcd/header.rb', line 42 def major_rev; @params[:major_rev]; end |
#minor_rev ⇒ Object
43 |
# File 'lib/tcd/header.rb', line 43 def minor_rev; @params[:minor_rev]; end |
#months_on_station_bits ⇒ Object
73 |
# File 'lib/tcd/header.rb', line 73 def months_on_station_bits; @params[:months_on_station_bits]; end |
#node_bits ⇒ Object
54 |
# File 'lib/tcd/header.rb', line 54 def node_bits; @params[:node_bits]; end |
#node_offset ⇒ Object
56 |
# File 'lib/tcd/header.rb', line 56 def node_offset; @params[:node_offset]; end |
#node_scale ⇒ Object
55 |
# File 'lib/tcd/header.rb', line 55 def node_scale; @params[:node_scale]; end |
#number_of_records ⇒ Object
37 |
# File 'lib/tcd/header.rb', line 37 def number_of_records; @params[:number_of_records]; end |
#number_of_years ⇒ Object
40 |
# File 'lib/tcd/header.rb', line 40 def number_of_years; @params[:number_of_years]; end |
#record_size_bits ⇒ Object
68 |
# File 'lib/tcd/header.rb', line 68 def record_size_bits; @params[:record_size_bits]; end |
#record_type_bits ⇒ Object
Record field parameters
63 |
# File 'lib/tcd/header.rb', line 63 def record_type_bits; @params[:record_type_bits]; end |
#restriction_bits ⇒ Object
89 |
# File 'lib/tcd/header.rb', line 89 def restriction_bits; @params[:restriction_bits]; end |
#restriction_size ⇒ Object
91 |
# File 'lib/tcd/header.rb', line 91 def restriction_size; @params[:restriction_size]; end |
#restriction_types ⇒ Object
90 |
# File 'lib/tcd/header.rb', line 90 def restriction_types; @params[:restriction_types]; end |
#speed_bits ⇒ Object
Bit field parameters
48 |
# File 'lib/tcd/header.rb', line 48 def speed_bits; @params[:speed_bits]; end |
#speed_offset ⇒ Object
50 |
# File 'lib/tcd/header.rb', line 50 def speed_offset; @params[:speed_offset]; end |
#speed_scale ⇒ Object
49 |
# File 'lib/tcd/header.rb', line 49 def speed_scale; @params[:speed_scale]; end |
#start_year ⇒ Object
39 |
# File 'lib/tcd/header.rb', line 39 def start_year; @params[:start_year]; end |
#station_bits ⇒ Object
69 |
# File 'lib/tcd/header.rb', line 69 def station_bits; @params[:station_bits]; end |
#time_bits ⇒ Object
75 |
# File 'lib/tcd/header.rb', line 75 def time_bits; @params[:time_bits]; end |
#tzfile_bits ⇒ Object
100 |
# File 'lib/tcd/header.rb', line 100 def tzfile_bits; @params[:tzfile_bits]; end |
#tzfile_size ⇒ Object
102 |
# File 'lib/tcd/header.rb', line 102 def tzfile_size; @params[:tzfile_size]; end |
#tzfiles ⇒ Object
101 |
# File 'lib/tcd/header.rb', line 101 def tzfiles; @params[:tzfiles]; end |
#version ⇒ Object
41 |
# File 'lib/tcd/header.rb', line 41 def version; @params[:version]; end |