Class: Zippo::BinaryStructure::Structure
- Inherits:
-
Object
- Object
- Zippo::BinaryStructure::Structure
- Defined in:
- lib/zippo/binary_structure/structure.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#owner_class ⇒ Object
readonly
Returns the value of attribute owner_class.
Class Method Summary collapse
Instance Method Summary collapse
- #dependent?(field_name) ⇒ Boolean
- #field(name, pack, options = {}) ⇒ Object
-
#initialize(owner_class, &block) ⇒ Structure
constructor
A new instance of Structure.
Constructor Details
#initialize(owner_class, &block) ⇒ Structure
Returns a new instance of Structure.
8 9 10 11 12 |
# File 'lib/zippo/binary_structure/structure.rb', line 8 def initialize(owner_class, &block) @fields = [] @owner_class = owner_class instance_eval &block end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
21 22 23 |
# File 'lib/zippo/binary_structure/structure.rb', line 21 def fields @fields end |
#owner_class ⇒ Object (readonly)
Returns the value of attribute owner_class.
21 22 23 |
# File 'lib/zippo/binary_structure/structure.rb', line 21 def owner_class @owner_class end |
Class Method Details
.create(owner_class, &block) ⇒ Object
4 5 6 7 |
# File 'lib/zippo/binary_structure/structure.rb', line 4 def self.create(owner_class, &block) structure = new(owner_class, &block) structure end |
Instance Method Details
#dependent?(field_name) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/zippo/binary_structure/structure.rb', line 16 def dependent? field_name fields.detect do |field| field.[:size] == field_name end end |
#field(name, pack, options = {}) ⇒ Object
13 14 15 |
# File 'lib/zippo/binary_structure/structure.rb', line 13 def field name, pack, = {} @fields << StructureMember.new(name, pack, ) end |