Class: Buffer::View
- Includes:
- Native::Wrapper
- Defined in:
- opal/stdlib/buffer/view.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Class Method Summary collapse
Instance Method Summary collapse
- #get(offset, bits = 8, type = :unsigned, little = false) ⇒ Object (also: #[])
- #get_float32(offset, little = false) ⇒ Object
- #get_float64(offset, little = false) ⇒ Object
- #get_int16(offset, little = false) ⇒ Object
- #get_int32(offset, little = false) ⇒ Object
- #get_int8(offset, little = false) ⇒ Object
- #get_uint16(offset, little = false) ⇒ Object
- #get_uint32(offset, little = false) ⇒ Object
- #get_uint8(offset, little = false) ⇒ Object
-
#initialize(buffer, offset = nil, length = nil) ⇒ View
constructor
A new instance of View.
- #length ⇒ Object (also: #size)
- #set(offset, value, bits = 8, type = :unsigned, little = false) ⇒ Object (also: #[]=)
- #set_float32(offset, value, little = false) ⇒ Object
- #set_float64(offset, value, little = false) ⇒ Object
- #set_int16(offset, value, little = false) ⇒ Object
- #set_int32(offset, value, little = false) ⇒ Object
- #set_int8(offset, value, little = false) ⇒ Object
- #set_uint16(offset, value, little = false) ⇒ Object
- #set_uint32(offset, value, little = false) ⇒ Object
- #set_uint8(offset, value, little = false) ⇒ Object
Methods included from Native::Wrapper
Constructor Details
#initialize(buffer, offset = nil, length = nil) ⇒ View
Returns a new instance of View.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'opal/stdlib/buffer/view.rb', line 13 def initialize(buffer, offset = nil, length = nil) if native?(buffer) super(buffer) elsif offset && length super(`new DataView(#{buffer.to_n}, #{offset.to_n}, #{length.to_n})`) elsif offset super(`new DataView(#{buffer.to_n}, #{offset.to_n})`) else super(`new DataView(#{buffer.to_n})`) end @buffer = buffer @offset = offset end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
11 12 13 |
# File 'opal/stdlib/buffer/view.rb', line 11 def buffer @buffer end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
11 12 13 |
# File 'opal/stdlib/buffer/view.rb', line 11 def offset @offset end |
Class Method Details
.supported? ⇒ Boolean
7 8 9 |
# File 'opal/stdlib/buffer/view.rb', line 7 def self.supported? !$$[:DataView].nil? end |
Instance Method Details
#get(offset, bits = 8, type = :unsigned, little = false) ⇒ Object Also known as: []
32 33 34 |
# File 'opal/stdlib/buffer/view.rb', line 32 def get(offset, bits = 8, type = :unsigned, little = false) `#{@native}["get" + #{Buffer.name_for bits, type}](offset, little)` end |
#get_float32(offset, little = false) ⇒ Object
92 93 94 |
# File 'opal/stdlib/buffer/view.rb', line 92 def get_float32(offset, little = false) `#{@native}.getFloat32(offset, little)` end |
#get_float64(offset, little = false) ⇒ Object
100 101 102 |
# File 'opal/stdlib/buffer/view.rb', line 100 def get_float64(offset, little = false) `#{@native}.getFloat64(offset, little)` end |
#get_int16(offset, little = false) ⇒ Object
60 61 62 |
# File 'opal/stdlib/buffer/view.rb', line 60 def get_int16(offset, little = false) `#{@native}.getInt16(offset, little)` end |
#get_int32(offset, little = false) ⇒ Object
76 77 78 |
# File 'opal/stdlib/buffer/view.rb', line 76 def get_int32(offset, little = false) `#{@native}.getInt32(offset, little)` end |
#get_int8(offset, little = false) ⇒ Object
44 45 46 |
# File 'opal/stdlib/buffer/view.rb', line 44 def get_int8(offset, little = false) `#{@native}.getInt8(offset, little)` end |
#get_uint16(offset, little = false) ⇒ Object
68 69 70 |
# File 'opal/stdlib/buffer/view.rb', line 68 def get_uint16(offset, little = false) `#{@native}.getUint16(offset, little)` end |
#get_uint32(offset, little = false) ⇒ Object
84 85 86 |
# File 'opal/stdlib/buffer/view.rb', line 84 def get_uint32(offset, little = false) `#{@native}.getUint32(offset, little)` end |
#get_uint8(offset, little = false) ⇒ Object
52 53 54 |
# File 'opal/stdlib/buffer/view.rb', line 52 def get_uint8(offset, little = false) `#{@native}.getUint8(offset, little)` end |
#length ⇒ Object Also known as: size
28 29 30 |
# File 'opal/stdlib/buffer/view.rb', line 28 def length `#{@native}.byteLength` end |
#set(offset, value, bits = 8, type = :unsigned, little = false) ⇒ Object Also known as: []=
38 39 40 |
# File 'opal/stdlib/buffer/view.rb', line 38 def set(offset, value, bits = 8, type = :unsigned, little = false) `#{@native}["set" + #{Buffer.name_for bits, type}](offset, value, little)` end |
#set_float32(offset, value, little = false) ⇒ Object
96 97 98 |
# File 'opal/stdlib/buffer/view.rb', line 96 def set_float32(offset, value, little = false) `#{@native}.setFloat32(offset, value, little)` end |
#set_float64(offset, value, little = false) ⇒ Object
104 105 106 |
# File 'opal/stdlib/buffer/view.rb', line 104 def set_float64(offset, value, little = false) `#{@native}.setFloat64(offset, value, little)` end |
#set_int16(offset, value, little = false) ⇒ Object
64 65 66 |
# File 'opal/stdlib/buffer/view.rb', line 64 def set_int16(offset, value, little = false) `#{@native}.setInt16(offset, value, little)` end |
#set_int32(offset, value, little = false) ⇒ Object
80 81 82 |
# File 'opal/stdlib/buffer/view.rb', line 80 def set_int32(offset, value, little = false) `#{@native}.setInt32(offset, value, little)` end |
#set_int8(offset, value, little = false) ⇒ Object
48 49 50 |
# File 'opal/stdlib/buffer/view.rb', line 48 def set_int8(offset, value, little = false) `#{@native}.setInt8(offset, value, little)` end |
#set_uint16(offset, value, little = false) ⇒ Object
72 73 74 |
# File 'opal/stdlib/buffer/view.rb', line 72 def set_uint16(offset, value, little = false) `#{@native}.setUint16(offset, value, little)` end |
#set_uint32(offset, value, little = false) ⇒ Object
88 89 90 |
# File 'opal/stdlib/buffer/view.rb', line 88 def set_uint32(offset, value, little = false) `#{@native}.setUint32(offset, value, little)` end |
#set_uint8(offset, value, little = false) ⇒ Object
56 57 58 |
# File 'opal/stdlib/buffer/view.rb', line 56 def set_uint8(offset, value, little = false) `#{@native}.setUint8(offset, value, little)` end |