Skip to content

Instantly share code, notes, and snippets.

@xander-miller
Created October 18, 2014 19:17
Show Gist options
  • Select an option

  • Save xander-miller/27a4bd68e6c3d990595b to your computer and use it in GitHub Desktop.

Select an option

Save xander-miller/27a4bd68e6c3d990595b to your computer and use it in GitHub Desktop.
class ArrayModifier
attr_reader :array
def initialize(array)
@array = array
end
def exclaim
new_array = []
array.each do |sentence|
new_array << "#{sentence}!"
end
new_array
end
def capsify
new_array = []
array.each do |word|
new_array << word.upcase
end
new_array
end
end
class StringModifier
attr_reader :string
def initialize(string)
@string = string
end
def proclaim
new_array = []
string.split.each do |word|
new_array << "#{word}!"
end
new_array.join(' ')
end
## Extra Credit solution
# def proclaim
# ArrayModifier.new(string.split).exclaim.join(' ')
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment