From: Tim Roberts Date: 2010-11-24T14:55:22+09:00 Subject: Re: BitStruct-28bit-Ruby Beginner Jaikanth Krishnaswamy wrote: >Hi , >I am a beginner to Ruby. I am using the ruby 1.9.2p0 (2010-08-18 >revision 29036) [i686-linux] and bit-struct (0.13.6) >I am trying to construct a 28 bit length data element in my class And did you read the documentation that says BitStruct supports fields of size 1 to 16, or multiples of 8? 28 is not a supported size. >and am getting the following >error./usr/local/ruby/lib/ruby/gems/1.9.1/gems/bit-struct-0.13.6/lib/bit-struct/unsigned-field.rb:244:in >`add_accessors_to': unsupported: That says you're using ruby 1.9.1, not that it matters much. The error is telling you that 28 bits is not a valid size. >I am hoping somebody can direct me to an example of how I can achieve a >28 bit field with BitStruct or some other technique.. Perhaps you should describe what you are actually trying to do. Are you trying to parse a file that contains fields of oddly-sized data? There may be easier ways. If nothing else, you can compose your field out of smaller sizes, like one fields of 24 bits and an adjacent field of 4 bits. It depends on what your actual task is. -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc.