Created
October 18, 2014 19:17
-
-
Save xander-miller/27a4bd68e6c3d990595b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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