Skip to content

Commit

Permalink
working on new method. removed debug line
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoertink committed Oct 21, 2016
1 parent 1a3a995 commit ef9ef03
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions spec/note_spec.cr
Expand Up @@ -29,4 +29,11 @@ describe Medley::Note do
end
end

describe ".halfstep_down" do
it "returns G when given G#" do
note = Medley::Note.new("G#")
note.halfstep_down.should eq "G"
end
end

end
15 changes: 14 additions & 1 deletion src/medley/note.cr
Expand Up @@ -57,12 +57,25 @@ module Medley
when .double_flat?
@current_note[0..1].to_s
when .double_sharp?
puts "double sharp #{@current_note}"
aliased = ALIASES[@current_note]
return "#{aliased}#"
end
end

def halfstep_down
case self
when .natural?, .flat?
return "#{@current_note}b"
when .sharp?
return @current_note[0].to_s
when .double_sharp?
@current_note[0..1].to_s
when .double_flat?
aliased = ALIASES[@current_note]
return "#{aliased}b"
end
end

def wholestep_up
new_note = Note.new(halfstep_up, @current_note)
new_note.halfstep_up
Expand Down

0 comments on commit ef9ef03

Please sign in to comment.