Created
September 26, 2015 20:09
-
-
Save mikhailov/7c5c89601fa5c92122ce to your computer and use it in GitHub Desktop.
ReverseSentence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReverseSentence | |
def initialize(string) | |
@array, @array_reversed = string.split(" "), [] | |
end | |
def process | |
@array_reversed << @array.pop while @array.any? | |
@array_reversed.join(" ") | |
end | |
end | |
require 'minitest/autorun' | |
class ReverseSentenceTest < Minitest::Unit::TestCase | |
def test_process | |
assert_equal "dogs likes bob", ReverseSentence.new("bob likes dogs").process | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment