Skip to content

Instantly share code, notes, and snippets.

@ryanswood
Created August 21, 2014 04:43
Show Gist options
  • Select an option

  • Save ryanswood/c5f8e93305c4654b658b to your computer and use it in GitHub Desktop.

Select an option

Save ryanswood/c5f8e93305c4654b658b to your computer and use it in GitHub Desktop.
class PigLatin
def initialize
end
def convert(original_string)
word_collection = original_string.split(" ").map(&:downcase)
word_collection.map! do |word|
word.match(/(.)(.+)/)
$2 + $1 + "ay"
end
word_collection.join(" ")
end
end
require './pig_latin'
describe PigLatin do
let(:pl) { PigLatin.new }
describe "#converter" do
it "accepts an argument" do
expect{pl.convert("Hello, World")}.not_to raise_error
end
it "returns the correct output" do
expect(pl.convert("Hello World")).to eq("ellohay orldway")
end
end
end
@ready4god2513
Copy link

p = Piglatin.new
p.convert("a")

Boom!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment