Class: CStruct::Field
- Inherits:
-
Object
- Object
- CStruct::Field
- Defined in:
- lib/cstruct/field.rb
Overview
:nodoc: all
Instance Attribute Summary collapse
-
#dimension ⇒ Object
Returns the value of attribute dimension.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#sign ⇒ Object
Returns the value of attribute sign.
-
#size ⇒ Object
Returns the value of attribute size.
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
- #byte_size ⇒ Object
-
#initialize(tag, size, offset, sign, dimension = nil, *args) ⇒ Field
constructor
A new instance of Field.
- #is_double? ⇒ Boolean
- #is_float? ⇒ Boolean
- #is_struct? ⇒ Boolean
- #is_union? ⇒ Boolean
Constructor Details
#initialize(tag, size, offset, sign, dimension = nil, *args) ⇒ Field
Returns a new instance of Field.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cstruct/field.rb', line 9 def initialize(tag,size,offset,sign,dimension = nil,*args) @tag = tag @size = size @offset = offset @sign = sign @dimension = dimension @byte_size = size if @dimension @byte_size = @size * dimension.inject(1){|m,i| m*=i} @sign = :struct_array if @sign == :struct end end |
Instance Attribute Details
#dimension ⇒ Object
Returns the value of attribute dimension.
7 8 9 |
# File 'lib/cstruct/field.rb', line 7 def dimension @dimension end |
#offset ⇒ Object
Returns the value of attribute offset.
5 6 7 |
# File 'lib/cstruct/field.rb', line 5 def offset @offset end |
#sign ⇒ Object
Returns the value of attribute sign.
6 7 8 |
# File 'lib/cstruct/field.rb', line 6 def sign @sign end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/cstruct/field.rb', line 4 def size @size end |
#tag ⇒ Object
Returns the value of attribute tag.
3 4 5 |
# File 'lib/cstruct/field.rb', line 3 def tag @tag end |
Instance Method Details
#byte_size ⇒ Object
24 25 26 |
# File 'lib/cstruct/field.rb', line 24 def byte_size @byte_size end |
#is_double? ⇒ Boolean
32 33 34 |
# File 'lib/cstruct/field.rb', line 32 def is_double? @sign == :double end |
#is_float? ⇒ Boolean
28 29 30 |
# File 'lib/cstruct/field.rb', line 28 def is_float? @sign == :float end |
#is_struct? ⇒ Boolean
36 37 38 |
# File 'lib/cstruct/field.rb', line 36 def is_struct? @sign == :struct end |
#is_union? ⇒ Boolean
40 41 42 |
# File 'lib/cstruct/field.rb', line 40 def is_union? @sign == :union end |