Class: TCD::Header

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#paramsObject (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_bitsObject



57
# File 'lib/tcd/header.rb', line 57

def amplitude_bits;    @params[:amplitude_bits]; end

#amplitude_scaleObject



58
# File 'lib/tcd/header.rb', line 58

def amplitude_scale;   @params[:amplitude_scale]; end

#confidence_value_bitsObject



74
# File 'lib/tcd/header.rb', line 74

def confidence_value_bits; @params[:confidence_value_bits]; end

#constituent_bitsObject



98
# File 'lib/tcd/header.rb', line 98

def constituent_bits;  @params[:constituent_bits]; end

#constituent_sizeObject



99
# File 'lib/tcd/header.rb', line 99

def constituent_size;  @params[:constituent_size]; end

#constituentsObject



38
# File 'lib/tcd/header.rb', line 38

def constituents;      @params[:constituents]; end

#countriesObject



104
# File 'lib/tcd/header.rb', line 104

def countries;         @params[:countries]; end

#country_bitsObject



103
# File 'lib/tcd/header.rb', line 103

def country_bits;      @params[:country_bits]; end

#country_sizeObject



105
# File 'lib/tcd/header.rb', line 105

def country_size;      @params[:country_size]; end

#date_bitsObject



72
# File 'lib/tcd/header.rb', line 72

def date_bits;         @params[:date_bits]; end

#datum_bitsObject



92
# File 'lib/tcd/header.rb', line 92

def datum_bits;        @params[:datum_bits]; end

#datum_offset_bitsObject



70
# File 'lib/tcd/header.rb', line 70

def datum_offset_bits; @params[:datum_offset_bits]; end

#datum_offset_scaleObject



71
# File 'lib/tcd/header.rb', line 71

def datum_offset_scale; @params[:datum_offset_scale]; end

#datum_sizeObject



94
# File 'lib/tcd/header.rb', line 94

def datum_size;        @params[:datum_size]; end

#datum_typesObject



93
# File 'lib/tcd/header.rb', line 93

def datum_types;       @params[:datum_types]; end

#direction_bitsObject



80
# File 'lib/tcd/header.rb', line 80

def direction_bits;    @params[:direction_bits]; end

#direction_unit_bitsObject



86
# File 'lib/tcd/header.rb', line 86

def direction_unit_bits; @params[:direction_unit_bits]; end

#direction_unit_sizeObject



88
# File 'lib/tcd/header.rb', line 88

def direction_unit_size; @params[:direction_unit_size]; end

#direction_unit_typesObject



87
# File 'lib/tcd/header.rb', line 87

def direction_unit_types; @params[:direction_unit_types]; end

#end_of_fileObject



45
# File 'lib/tcd/header.rb', line 45

def end_of_file;       @params[:end_of_file]; end

#epoch_bitsObject



59
# File 'lib/tcd/header.rb', line 59

def epoch_bits;        @params[:epoch_bits]; end

#epoch_scaleObject



60
# File 'lib/tcd/header.rb', line 60

def epoch_scale;       @params[:epoch_scale]; end

#equilibrium_bitsObject



51
# File 'lib/tcd/header.rb', line 51

def equilibrium_bits;  @params[:equilibrium_bits]; end

#equilibrium_offsetObject



53
# File 'lib/tcd/header.rb', line 53

def equilibrium_offset; @params[:equilibrium_offset]; end

#equilibrium_scaleObject



52
# File 'lib/tcd/header.rb', line 52

def equilibrium_scale; @params[:equilibrium_scale]; end

#header_sizeObject

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

Returns:

  • (Boolean)


26
27
28
# File 'lib/tcd/header.rb', line 26

def key?(key)
    @params.key?(key)
end

#keysObject

All parameter keys



31
32
33
# File 'lib/tcd/header.rb', line 31

def keys
    @params.keys
end

#last_modifiedObject



44
# File 'lib/tcd/header.rb', line 44

def last_modified;     @params[:last_modified]; end

#latitude_bitsObject



64
# File 'lib/tcd/header.rb', line 64

def latitude_bits;     @params[:latitude_bits]; end

#latitude_scaleObject



65
# File 'lib/tcd/header.rb', line 65

def latitude_scale;    @params[:latitude_scale]; end

#legalese_bitsObject



95
# File 'lib/tcd/header.rb', line 95

def legalese_bits;     @params[:legalese_bits]; end

#legalese_sizeObject



97
# File 'lib/tcd/header.rb', line 97

def legalese_size;     @params[:legalese_size]; end

#legalese_typesObject



96
# File 'lib/tcd/header.rb', line 96

def legalese_types;    @params[:legalese_types]; end

#level_add_bitsObject



76
# File 'lib/tcd/header.rb', line 76

def level_add_bits;    @params[:level_add_bits]; end

#level_add_scaleObject



77
# File 'lib/tcd/header.rb', line 77

def level_add_scale;   @params[:level_add_scale]; end

#level_multiply_bitsObject



78
# File 'lib/tcd/header.rb', line 78

def level_multiply_bits; @params[:level_multiply_bits]; end

#level_multiply_scaleObject



79
# File 'lib/tcd/header.rb', line 79

def level_multiply_scale; @params[:level_multiply_scale]; end

#level_unit_bitsObject

Lookup table parameters



83
# File 'lib/tcd/header.rb', line 83

def level_unit_bits;   @params[:level_unit_bits]; end

#level_unit_sizeObject



85
# File 'lib/tcd/header.rb', line 85

def level_unit_size;   @params[:level_unit_size]; end

#level_unit_typesObject



84
# File 'lib/tcd/header.rb', line 84

def level_unit_types;  @params[:level_unit_types]; end

#longitude_bitsObject



66
# File 'lib/tcd/header.rb', line 66

def longitude_bits;    @params[:longitude_bits]; end

#longitude_scaleObject



67
# File 'lib/tcd/header.rb', line 67

def longitude_scale;   @params[:longitude_scale]; end

#major_revObject



42
# File 'lib/tcd/header.rb', line 42

def major_rev;         @params[:major_rev]; end

#minor_revObject



43
# File 'lib/tcd/header.rb', line 43

def minor_rev;         @params[:minor_rev]; end

#months_on_station_bitsObject



73
# File 'lib/tcd/header.rb', line 73

def months_on_station_bits; @params[:months_on_station_bits]; end

#node_bitsObject



54
# File 'lib/tcd/header.rb', line 54

def node_bits;         @params[:node_bits]; end

#node_offsetObject



56
# File 'lib/tcd/header.rb', line 56

def node_offset;       @params[:node_offset]; end

#node_scaleObject



55
# File 'lib/tcd/header.rb', line 55

def node_scale;        @params[:node_scale]; end

#number_of_recordsObject



37
# File 'lib/tcd/header.rb', line 37

def number_of_records; @params[:number_of_records]; end

#number_of_yearsObject



40
# File 'lib/tcd/header.rb', line 40

def number_of_years;   @params[:number_of_years]; end

#record_size_bitsObject



68
# File 'lib/tcd/header.rb', line 68

def record_size_bits;  @params[:record_size_bits]; end

#record_type_bitsObject

Record field parameters



63
# File 'lib/tcd/header.rb', line 63

def record_type_bits;  @params[:record_type_bits]; end

#restriction_bitsObject



89
# File 'lib/tcd/header.rb', line 89

def restriction_bits;  @params[:restriction_bits]; end

#restriction_sizeObject



91
# File 'lib/tcd/header.rb', line 91

def restriction_size;  @params[:restriction_size]; end

#restriction_typesObject



90
# File 'lib/tcd/header.rb', line 90

def restriction_types; @params[:restriction_types]; end

#speed_bitsObject

Bit field parameters



48
# File 'lib/tcd/header.rb', line 48

def speed_bits;        @params[:speed_bits]; end

#speed_offsetObject



50
# File 'lib/tcd/header.rb', line 50

def speed_offset;      @params[:speed_offset]; end

#speed_scaleObject



49
# File 'lib/tcd/header.rb', line 49

def speed_scale;       @params[:speed_scale]; end

#start_yearObject



39
# File 'lib/tcd/header.rb', line 39

def start_year;        @params[:start_year]; end

#station_bitsObject



69
# File 'lib/tcd/header.rb', line 69

def station_bits;      @params[:station_bits]; end

#time_bitsObject



75
# File 'lib/tcd/header.rb', line 75

def time_bits;         @params[:time_bits]; end

#tzfile_bitsObject



100
# File 'lib/tcd/header.rb', line 100

def tzfile_bits;       @params[:tzfile_bits]; end

#tzfile_sizeObject



102
# File 'lib/tcd/header.rb', line 102

def tzfile_size;       @params[:tzfile_size]; end

#tzfilesObject



101
# File 'lib/tcd/header.rb', line 101

def tzfiles;           @params[:tzfiles]; end

#versionObject



41
# File 'lib/tcd/header.rb', line 41

def version;           @params[:version]; end