Class: Ronin::Support::Binary::Struct::Member
- Inherits:
-
Object
- Object
- Ronin::Support::Binary::Struct::Member
- Defined in:
- lib/ronin/support/binary/struct/member.rb
Overview
Represents a member defined within a Ronin::Support::Binary::Struct.
Instance Attribute Summary collapse
-
#default ⇒ Object, ...
readonly
The default value for the structure member.
-
#name ⇒ Symbol
readonly
The name of the structure member.
-
#type_signature ⇒ Symbol, ...
readonly
The type signature of the structure member.
Instance Method Summary collapse
-
#default_value(struct) ⇒ Object?
Returns a default value for the structure's field.
-
#initialize(name, type_signature, default: nil) ⇒ Member
constructor
Initializes the structure member.
Constructor Details
#initialize(name, type_signature, default: nil) ⇒ Member
Initializes the structure member.
56 57 58 59 60 |
# File 'lib/ronin/support/binary/struct/member.rb', line 56 def initialize(name,type_signature, default: nil) @name = name @type_signature = type_signature @default = default end |
Instance Attribute Details
#default ⇒ Object, ... (readonly)
The default value for the structure member.
43 44 45 |
# File 'lib/ronin/support/binary/struct/member.rb', line 43 def default @default end |
#name ⇒ Symbol (readonly)
The name of the structure member.
33 34 35 |
# File 'lib/ronin/support/binary/struct/member.rb', line 33 def name @name end |
#type_signature ⇒ Symbol, ... (readonly)
The type signature of the structure member.
38 39 40 |
# File 'lib/ronin/support/binary/struct/member.rb', line 38 def type_signature @type_signature end |
Instance Method Details
#default_value(struct) ⇒ Object?
Returns a default value for the structure's field.
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ronin/support/binary/struct/member.rb', line 71 def default_value(struct) case @default when Proc if @default.arity == 1 @default.call(struct) else @default.call end else @default.dup end end |