Method: BitStruct::Field#describe
- Defined in:
- lib/bit-struct/field.rb
#describe(opts) {|["@%d" % byte_offset, class_name, name, len_str, display_name]| ... } ⇒ Object
Yield the description of this field, as an array of 5 strings: byte offset, type, name, size, and description. The opts hash may have:
- :expand
-
if the value is true, expand complex fields
(Subclass implementations may yield more than once for complex fields.)
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bit-struct/field.rb', line 52 def describe opts bits = size if bits > 32 and bits % 8 == 0 len_str = "%dB" % (bits/8) else len_str = "%db" % bits end byte_offset = offset / 8 + (opts[:byte_offset] || 0) yield ["@%d" % byte_offset, class_name, name, len_str, display_name] end |