The goal of this task is to implement module which can be used to truncate string attributes in any class, just by extending its functionality.
Given Message
class extended by Truncate
module and configured to truncate particular attribute in the following way truncate :body, length: 120
. Complete Truncate
module implementation.
- All work should be done in
truncate.rb
file - Ruby version doesn't matter
- You can't use anything except Ruby standard library. No gems allowed
body = "The fact that so many people make so much effort on the internet to make other random people from around the world laugh/feel better is a great achievement of the human race."
expected = "The fact that so many people make so much effort on the internet to make other random people from around the world laugh..."
expected == Message.new(body).body`
$ ruby task_1/test.rb
Given message body: The fact that so many people make so much effort on the internet to make other random people from around the world laugh/feel better is a great achievement of the human race.
--------------------------------------------------------------------------------
Processed message: The fact that so many people make so much effort on the internet to make other random people from around the world laugh...