Class: Haxe::Io::Bytes

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/haxe/io/bytes.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length, b) ⇒ Bytes

Returns a new instance of Bytes.



8
9
10
11
# File 'lib/lib/haxe/io/bytes.rb', line 8

def initialize(length,b)
  @length = length
  @b = b
end

Instance Attribute Details

#bObject

protected - in ruby this doesn’t play well with static/inline methods



17
18
19
# File 'lib/lib/haxe/io/bytes.rb', line 17

def b
  @b
end

#lengthObject

Returns the value of attribute length.



13
14
15
# File 'lib/lib/haxe/io/bytes.rb', line 13

def length
  @length
end

Class Method Details

.of_string(s) ⇒ Object



26
27
28
# File 'lib/lib/haxe/io/bytes.rb', line 26

def Bytes.of_string(s)
  ::Haxe::Io::Bytes.new(s.bytesize,s)
end

Instance Method Details

#get_string(pos, len) ⇒ Object



21
22
23
24
# File 'lib/lib/haxe/io/bytes.rb', line 21

def get_string(pos,len)
  raise hx_raise(::Haxe::Io::Error.outside_bounds) if pos < 0 || len < 0 || pos + len > @length
  @b.byteslice(pos,len)
end