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
23 24 25 |
# File 'lib/zippo/binary_structure/structure.rb', line 23 def fields @fields end |
#owner_class ⇒ Object (readonly)
Returns the value of attribute owner_class
23 24 25 |
# File 'lib/zippo/binary_structure/structure.rb', line 23 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
18 19 20 21 22 |
# File 'lib/zippo/binary_structure/structure.rb', line 18 def dependent?(field_name) fields.find do |field| field.[:size] == field_name end end |
#field(name, pack, options = {}) ⇒ Object
14 15 16 |
# File 'lib/zippo/binary_structure/structure.rb', line 14 def field(name, pack, = {}) @fields << StructureMember.new(name, pack, ) end |