Sha256: c688650857ffb5971bd180679fd7c5489cb0e577a89f5d397bcb2c011b930204

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

require 'bit_struct/field'

module BitStruct

  class NestedField < Field

    def initialize( name, nested_class, description = nil )
      super name, nil, description
      @nested_class = nested_class
    end

    def length
      @nested_class.length
    end

    def read( slicer )
      bytes = slicer.get_bytes
      @nested_class.new bytes
    end

    def write( slicer, new_value )
      # TODO: What should be allowed here?
      # TODO: new_value.is_a? String
      # TODO: new_value.is_a? Array
      # TODO: new_value.is_a? StructBase
      raise "NYI"
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
BitStructEx-0.0.54 src/ruby/bit_struct/nested.rb
BitStructEx-0.0.64 src/ruby/bit_struct/nested.rb
BitStructEx-0.0.65 src/ruby/bit_struct/nested.rb