Class: Win32::CaptureIE::FFI::Field
- Inherits:
-
Object
- Object
- Win32::CaptureIE::FFI::Field
- Defined in:
- lib/win32/capture_ie/ffi/struct.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#var ⇒ Object
readonly
Returns the value of attribute var.
Instance Method Summary collapse
- #array? ⇒ Boolean
- #init ⇒ Object
-
#initialize(type, name, opts = nil) ⇒ Field
constructor
A new instance of Field.
- #pack(value) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(type, name, opts = nil) ⇒ Field
Returns a new instance of Field.
153 154 155 156 157 158 159 160 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 153 def initialize(type, name, opts=nil) @type = type @name = name @var = "@#{name}".to_sym @opts = opts || {} @offset = @opts[:offset] || nil @count = @opts[:dim] || 1 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
151 152 153 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 151 def count @count end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
151 152 153 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 151 def name @name end |
#offset ⇒ Object
Returns the value of attribute offset.
152 153 154 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 152 def offset @offset end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
151 152 153 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 151 def type @type end |
#var ⇒ Object (readonly)
Returns the value of attribute var.
151 152 153 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 151 def var @var end |
Instance Method Details
#array? ⇒ Boolean
162 163 164 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 162 def array? count > 0 end |
#init ⇒ Object
166 167 168 169 170 171 172 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 166 def init if array? init_one else (0...count).map{ init_one } end end |
#pack(value) ⇒ Object
178 179 180 181 182 183 184 185 186 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 178 def pack(value) if count == 1 @type.pack(value) else raise "hoge" unless Array === value raise "foo" unless value.length == count value.map{|e| @type.pack(e) }.join end end |
#size ⇒ Object
174 175 176 |
# File 'lib/win32/capture_ie/ffi/struct.rb', line 174 def size @type.size * count end |