Class: Metro::Sample

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/metro/sample.rb

Overview

Sample is a wrapper class for a Gosu Sample. This allows for additional data to be stored without relying on monkey-patching on functionality.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sample, path) ⇒ Sample

Returns a new instance of Sample.



11
12
13
14
15
# File 'lib/metro/sample.rb', line 11

def initialize(sample,path)
  super(sample)
  @sample = sample
  @path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



9
10
11
# File 'lib/metro/sample.rb', line 9

def path
  @path
end

#sampleObject

Returns the value of attribute sample.



9
10
11
# File 'lib/metro/sample.rb', line 9

def sample
  @sample
end

Class Method Details

.create(options) ⇒ Object

Create a sample given the window and path.

Examples:

Creating a Sample


Metro::Sample.create window: model.window, path: "sample_path.wav"


24
25
26
27
28
# File 'lib/metro/sample.rb', line 24

def self.create(options)
  window, asset_path = create_params(options)
  gosu_sample = Gosu::Sample.new(window,asset_path.filepath)
  new gosu_sample, asset_path.path
end