Class: Mingle::Io::Headers

Inherits:
BitGirder::Core::BitGirderClass show all
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

Class 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

Class Method Details

.as_headers(val) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/mingle/io.rb', line 26

def self.as_headers( val )
    case val
        when Headers then val
        when Hash, MingleSymbolMap then Headers.new( :fields => val )
        else raise TypeError, "Invalid headers value: #{val.class}"
    end
end

.make_fields(flds) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mingle/io.rb', line 12

def self.make_fields( flds )
    
    pairs = flds.inject( {} ) do |h, pair|
        val = pair[ 1 ]
        val = val.external_form if val.is_a?( MingleIdentifier )
        val = MingleModels.as_mingle_value( val )
        val = MingleModels.as_mingle_string( val )
        h[ pair[ 0 ] ] = val
        h
    end

    MingleSymbolMap.create( pairs )
end