Class: Buffer
- Inherits:
-
Object
- Object
- Buffer
- Includes:
- Native
- Defined in:
- lib/opal/typed-array/view.rb,
lib/opal/typed-array/array.rb,
lib/opal/typed-array/buffer.rb
Overview
–
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
++
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(size, bits = 8) ⇒ Buffer
constructor
A new instance of Buffer.
- #length ⇒ Object (also: #size)
- #to_a(bits = 8, type = :unsigned) ⇒ Object
- #view(offset = nil, length = nil) ⇒ Object
Constructor Details
#initialize(size, bits = 8) ⇒ Buffer
Returns a new instance of Buffer.
25 26 27 |
# File 'lib/opal/typed-array/buffer.rb', line 25 def initialize (size, bits = 8) super(`new ArrayBuffer(size * (bits / 8))`) end |
Class Method Details
.name_for(bits, type) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/opal/typed-array/buffer.rb', line 15 def self.name_for (bits, type) "#{case type when :unsigned then 'Uint' when :signed then 'Int' when :float then 'Float' end}#{bits}" end |
Instance Method Details
#length ⇒ Object Also known as: size
29 30 31 |
# File 'lib/opal/typed-array/buffer.rb', line 29 def length `#@native.byteLength` end |