Class: Ruby2D::Sound

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby2d/sound.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Sound

Returns a new instance of Sound.



9
10
11
12
13
14
15
16
17
# File 'lib/ruby2d/sound.rb', line 9

def initialize(path)
  unless File.exist? path
    raise Error, "Cannot find audio file `#{path}`"
  end
  @path = path
  unless ext_init(@path)
    raise Error, "Sound `#{@path}` cannot be created"
  end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



7
8
9
# File 'lib/ruby2d/sound.rb', line 7

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/ruby2d/sound.rb', line 6

def path
  @path
end

Instance Method Details

#lengthObject

Returns the length in seconds



25
26
27
# File 'lib/ruby2d/sound.rb', line 25

def length
  ext_length
end

#playObject

Play the sound



20
21
22
# File 'lib/ruby2d/sound.rb', line 20

def play
  ext_play
end