class BitStruct::NestedField

Class for nesting a BitStruct as a field within another BitStruct. Declared with BitStruct.nest.

Public Class Methods

class_name() click to toggle source

Used in describe.

   # File lib/bit-struct/nested-field.rb
12 def self.class_name
13   @class_name ||= "nest"
14 end
new(*args) click to toggle source
Calls superclass method BitStruct::Field::new
  # File lib/bit-struct/nested-field.rb
7 def initialize(*args)
8   super
9 end

Public Instance Methods

class_name() click to toggle source
   # File lib/bit-struct/nested-field.rb
16 def class_name
17   @class_name ||= nested_class.name[/\w+$/]
18 end
describe(opts) { |desc| ... } click to toggle source
Calls superclass method BitStruct::Field#describe
   # File lib/bit-struct/nested-field.rb
24 def describe opts
25   if opts[:expand]
26     opts = opts.dup
27     opts[:byte_offset] = offset / 8
28     opts[:omit_header] = opts[:omit_footer] = true
29     nested_class.describe(nil, opts) {|desc| yield desc}
30   else
31     super
32   end
33 end
nested_class() click to toggle source
   # File lib/bit-struct/nested-field.rb
20 def nested_class
21   @nested_class ||= options[:nested_class] || options["nested_class"]
22 end