Class: Mingle::Io::Decoder

Inherits:
BitGirder::Core::BitGirderClass show all
Extended by:
Forwardable
Defined in:
lib/mingle/io.rb

Constant Summary

Constants included from BitGirder::Core::BitGirderMethods

BitGirder::Core::BitGirderMethods::PARAM_TYPE_ARG, BitGirder::Core::BitGirderMethods::PARAM_TYPE_ENVVAR, BitGirder::Core::BitGirderMethods::PARAM_TYPE_KEY

Instance Method Summary collapse

Methods included from BitGirder::Core::BitGirderMethods

argv_to_argh, check_fail_prefix, class_name_to_sym, code, compares_to, console, ext_to_class_name, ext_to_sym, has_env, has_key, has_keys, nonnegative, not_nil, positive, raisef, set_from_key, set_var, split_argv, sym_to_cli_switch, sym_to_ext_id, to_bool, unpack_argv_array, unpack_argv_hash, warn

Methods included from BitGirder::Core::BitGirderStructure

#==, included

Instance Method Details

#expect_type_code(expct) ⇒ Object



121
122
123
124
125
126
127
128
129
# File 'lib/mingle/io.rb', line 121

def expect_type_code( expct )
    
    unless ( act = read_type_code ) == expct
        
        tmpl = "Invalid type :code => 0x%08x (expected 0x%08x)"
        msg = sprintf( tmpl, act, expct )
        raise InvalidTypeCodeError.new( msg )
    end
end

#expect_version(expct, ver_typ) ⇒ Object



105
106
107
108
109
110
111
112
113
# File 'lib/mingle/io.rb', line 105

def expect_version( expct, ver_typ )
    
    unless ( ver = read_version ) == expct

        tmpl = "Invalid %s :version => 0x%08x (expected 0x%08x)"
        msg = sprintf( tmpl, ver_typ, ver, expct )
        raise InvalidVersionError.new( msg )
    end
end

#read_headersObject



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/mingle/io.rb', line 137

def read_headers
    
    expect_version( HEADERS_VERSION1, "headers" )

    flds = {}
    while true do

        case tc = read_type_code

            when TYPE_CODE_HEADERS_FIELD then read_header_field( flds )

            when TYPE_CODE_HEADERS_END 
                return Headers.new( :fields => flds )
            
            else 
                msg = sprintf( "Unknown type :code => 0x%08x", tc )
                raise InvalidTypeCodeError.new( msg )
        end
    end
end

#read_type_codeObject



116
117
118
# File 'lib/mingle/io.rb', line 116

def read_type_code
    read_int32
end

#read_versionObject



100
101
102
# File 'lib/mingle/io.rb', line 100

def read_version
    read_int32
end