Class: Ruby2D::Sound
- Inherits:
-
Object
- Object
- Ruby2D::Sound
- Defined in:
- lib/ruby2d/sound.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Sound
constructor
A new instance of Sound.
-
#play ⇒ Object
Play the sound.
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
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/ruby2d/sound.rb', line 7 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/ruby2d/sound.rb', line 6 def path @path end |
Instance Method Details
#play ⇒ Object
Play the sound
20 21 22 |
# File 'lib/ruby2d/sound.rb', line 20 def play ext_play end |