Class: Ruby2D::Sound

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby2d/sound.rb,
ext/ruby2d/ruby2d-opal.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
# File 'lib/ruby2d/sound.rb', line 9

def initialize(path)
  # TODO: Check if file exists
  init(path)
  @path = path
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#init(path) ⇒ Object



158
159
160
# File 'ext/ruby2d/ruby2d-opal.rb', line 158

def init(path)
  `#{self}.data = S2D.CreateSound(path);`
end

#playObject



162
163
164
# File 'ext/ruby2d/ruby2d-opal.rb', line 162

def play
  `S2D.PlaySound(#{self}.data);`
end