Permalink
Browse files

impl tempo and time

  • Loading branch information...
1 parent 1b67e62 commit 51c7ff7bf6fead1521fe9edffab12f33dabf3620 @siuying committed Mar 11, 2012
Showing with 30 additions and 5 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 Gemfile
  3. +16 −2 lib/rubberband/options.rb
  4. +10 −2 spec/options_spec.rb
  5. +1 −0 spec/spec_helper.rb
View
@@ -8,6 +8,8 @@ rdoc
doc
.yardoc
+Gemfile.lock
+
# bundler
.bundle
View
@@ -9,5 +9,5 @@ group :development do
gem "rspec", "~> 2.3.0"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.6.4"
- gem "rcov", ">= 0"
+ gem "pry"
end
View
@@ -1,17 +1,31 @@
module Rubberband
class Options < Hash
- def initialized(options={})
+ def initialize(options={})
merge!(options)
end
def to_s
- params = collect do |key, val|
+ params = collect do |key, value|
send("convert_#{key}", value) if value && supports_option?(key)
end
params_string = params.join(" ")
params_string << " -q"
params_string
end
+
+ private
+ def supports_option?(option)
+ option = RUBY_VERSION < "1.9" ? "convert_#{option}" : "convert_#{option}".to_sym
+ private_methods.include?(option)
+ end
+
+ def convert_time(value)
+ "--time #{value}"
+ end
+
+ def convert_tempo(value)
+ "--tempo #{value}"
+ end
end
end
View
@@ -10,8 +10,16 @@
end
describe "configurable parameters" do
- it "should support time"
- it "should support tempo"
+ it "should support time" do
+ o = Rubberband::Options.new(:time => "360")
+ o.to_s.should =~ /--time 360/
+ end
+
+ it "should support tempo" do
+ o = Rubberband::Options.new(:tempo => 360)
+ o.to_s.should =~ /--tempo 360/
+ end
+
it "should support duration"
it "should support pitch"
it "should support frequency"
View
@@ -2,6 +2,7 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'rubberband-audio'
+require 'pry'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.

0 comments on commit 51c7ff7

Please sign in to comment.