Class: Mingle::BinWriter

Inherits:
BinIoBase
  • Object
show all
Defined in:
lib/mingle.rb

Constant Summary

Constants included from IoConstants

IoConstants::TYPE_CODE_ATOM_TYP, IoConstants::TYPE_CODE_BOOL, IoConstants::TYPE_CODE_BUFFER, IoConstants::TYPE_CODE_DECL_NM, IoConstants::TYPE_CODE_END, IoConstants::TYPE_CODE_ENUM, IoConstants::TYPE_CODE_FLOAT32, IoConstants::TYPE_CODE_FLOAT64, IoConstants::TYPE_CODE_ID, IoConstants::TYPE_CODE_INT32, IoConstants::TYPE_CODE_INT64, IoConstants::TYPE_CODE_LIST, IoConstants::TYPE_CODE_LIST_TYP, IoConstants::TYPE_CODE_MAP_PAIR, IoConstants::TYPE_CODE_NIL, IoConstants::TYPE_CODE_NS, IoConstants::TYPE_CODE_NULLABLE_TYP, IoConstants::TYPE_CODE_QN, IoConstants::TYPE_CODE_RANGE_RESTRICT, IoConstants::TYPE_CODE_REGEX_RESTRICT, IoConstants::TYPE_CODE_STRING, IoConstants::TYPE_CODE_STRUCT, IoConstants::TYPE_CODE_SYM_MAP, IoConstants::TYPE_CODE_TIME_RFC3339

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.as_bin_writer(io_wr) ⇒ Object



2839
2840
2841
# File 'lib/mingle.rb', line 2839

def self.as_bin_writer( io_wr )
    self.send( :new, :wr => io_wr )
end

Instance Method Details

#write_identifier(id) ⇒ Object



2776
2777
2778
2779
2780
2781
2782
# File 'lib/mingle.rb', line 2776

def write_identifier( id )
    
    write_type_code( TYPE_CODE_ID )

    @wr.write_uint8( id.parts.size )
    id.parts.each { |part| @wr.write_buffer32( part ) }
end

#write_type_reference(typ) ⇒ Object



2829
2830
2831
2832
2833
2834
2835
2836
2837
# File 'lib/mingle.rb', line 2829

def write_type_reference( typ )
    
    case typ
    when AtomicTypeReference then write_atomic_type_reference( typ )
    when ListTypeReference then write_list_type_reference( typ )
    when NullableTypeReference then write_nullable_type_reference( typ )
    else raise error( "Unhandled type reference: #{typ.class}" )
    end
end