Last active
August 29, 2015 14:08
-
-
Save xander-miller/230524a2b2394d0f69ec to your computer and use it in GitHub Desktop.
1loopy.rb
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