Module: PackedStruct
- Defined in:
- lib/packed_struct.rb,
lib/packed_struct/package.rb,
lib/packed_struct/version.rb,
lib/packed_struct/modifier.rb,
lib/packed_struct/directive.rb
Overview
Create structs to manage packed strings.
Defined Under Namespace
Classes: Directive, Modifier, Package, UnknownModifierError
Constant Summary collapse
- VERSION =
The current version of PackedStruct.
"0.4.1".freeze
Class Method Summary collapse
-
.included(reciever) ⇒ void
private
Called when this is included into another module.
Instance Method Summary collapse
-
#struct_layout(name = nil) { ... } ⇒ Package, Hash<Symbol, Package>
Define a struct.
-
#structs ⇒ Package, Hash<Symbol, Package>
(also: #struct)
The structs that were defined on the module that included this.
Class Method Details
.included(reciever) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Called when this is included into another module.
44 45 46 |
# File 'lib/packed_struct.rb', line 44 def self.included(reciever) reciever.extend self end |
Instance Method Details
#struct_layout(name = nil) { ... } ⇒ Package, Hash<Symbol, Package>
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/packed_struct.rb', line 27 def struct_layout(name = nil, &block) structs[name] = Package.new structs[name].instance_exec &block structs[name].finalize_directives! if name == nil @structs = structs[name] end structs end |
#structs ⇒ Package, Hash<Symbol, Package> Also known as: struct
The structs that were defined on the module that included this. If the structs were defined without a name, this will be the one and only struct that was defined (or the last one that was defined).
14 15 16 |
# File 'lib/packed_struct.rb', line 14 def structs @structs ||= {} end |