Class: CAStruct::Builder::Member
Overview
:nodoc:
Instance Attribute Summary collapse
-
#byte_length ⇒ Object
readonly
Returns the value of attribute byte_length.
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type, opt = {}) ⇒ Member
constructor
:nodoc:.
Constructor Details
#initialize(name, type, opt = {}) ⇒ Member
:nodoc:
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/carray/struct.rb', line 297 def initialize (name, type, opt={}) @name, @type, @opt = name, type, opt if @type.kind_of?(CArray) @type = @type.to_ca @byte_length = @type.bytes * @type.elements @bytes = 0 else data_type, @bytes = CArray.guess_type_and_bytes(@type, @opt[:bytes]) if data_type == CA_OBJECT raise RuntimeError, "CA_OBJECT type can't be a member of struct or union" end @byte_length = @bytes end @offset = @opt[:offset] end |
Instance Attribute Details
#byte_length ⇒ Object (readonly)
Returns the value of attribute byte_length.
313 314 315 |
# File 'lib/carray/struct.rb', line 313 def byte_length @byte_length end |
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
313 314 315 |
# File 'lib/carray/struct.rb', line 313 def bytes @bytes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
313 314 315 |
# File 'lib/carray/struct.rb', line 313 def name @name end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
313 314 315 |
# File 'lib/carray/struct.rb', line 313 def offset @offset end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
313 314 315 |
# File 'lib/carray/struct.rb', line 313 def type @type end |