-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Milestone/Project 2: feature - decorators 🎫 #2
Conversation
- Add 'Nameable' class interface. - Add 'BaseDecorator' class base decorator. - Add 'CapitalizeDecorator' class decorator inheriting from 'BaseDecorator'. - Add 'TrimmerDecorator' class decorator inheriting from 'BaseDecorator'.
- Include 'Nameable' class as an interface, which defines the 'correct_name' method. - In the 'Person' class, call super in the constructor to ensure proper initialization. - Implement the 'correct_name' method to meet the requirements of the 'Nameable' class interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status: Approved ✔️
Hi @ITurres👋🏽,
Your project is complete! There is nothing else to say other than... it's time to merge it
Congratulations! 🎉
Highlights
- Created a class Nameable that has a method correct_name implemented✔️
- Created a base Decorator class that implements the correct_name method which returns the result of the correct_name method of the @nameable✔️
- Created a CapitalizeDecorator class that implements a method correct_name which capitalizes the output of @nameable.correct_name✔️
- Created a TrimmerDecorator class that implements a method correct_name which makes sure that the output of @nameable.correct_name has a maximum of 10 characters✔
- The App works as expected✔
Optional suggestions
Every comment with the [OPTIONAL] prefix won't stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better. Some of them were simply missed by the previous reviewer and addressing them will really improve your application.
Cheers and Happy coding!👏👏👏
Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, remember to tag me in your question so I can receive the notification.
As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.
lib/class_decorators/nameable.rb
Outdated
class BaseDecorator < Nameable | ||
attr_accessor :nameable | ||
|
||
def initialize(nameable) | ||
super() | ||
@nameable = nameable | ||
end | ||
|
||
def correct_name | ||
@nameable.correct_name | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [OPTIONAL] I suggest you put this code in a seperate .rb file. Doing this will help organize your code more efficiently.👍
lib/class_decorators/nameable.rb
Outdated
class CapitalizeDecorator < BaseDecorator | ||
def correct_name | ||
@nameable.correct_name.capitalize | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [OPTIONAL] I suggest you put this code in a seperate .rb file. Doing this will help organize your code more efficiently.👍
lib/class_decorators/nameable.rb
Outdated
class TrimmerDecorator < BaseDecorator | ||
def correct_name | ||
@nameable.correct_name[0...10] unless @nameable.correct_name.length <= 10 | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [OPTIONAL] I suggest you put this code in a seperate .rb file. Doing this will help organize your code more efficiently.👍
Hi @Johnadibe John! how are you? absolutely! 🎯, you know, modularizing the decorators was my first approach 😄, however, I encountered the error that both the string modifier decorators were missing when I instantiated them on Such as: require_relative 'class_decorators/capitalize_decorator'
require_relative 'class_decorators/trimmer_decorator' What do you think? 🤠 |
Hello @ITurres, I believe it is okay if you do that.👍 |
Great then, thank you @Johnadibe John for having reviewed this PR! 👍🏼, wish you a great week and happy coding! 🎆 |
- Move 'BaseDecorator', 'CapitalizeDecorator', and 'TrimmerDecorator' in 'nameable.rb' to their own files.
🚩I have made the following changes to complete OOP School Library - Milestone/Project 2
Here is a summary of what has been done
Type of
files
changed/addedIn this new Branch, I have ➕ADDED➕ the succeeding *📂 folders and/or **📄 files to complete this milestone's requirements
*📂 root/
*📂 lib/
**📄 nameable.rb ➕
The
-Nameable-
class will raise theNotImplementedError
exception if thecorrect_name
method is not implemented.The
-BaseDecorator-
will inherits from-Nameable-
.In its constructor it will get the
nameable
object and assign it to the@nameable
attribute.It will also implement the
correct_name
method returning the@nameable
object'scorrect_name
method.-CapitalizeDecorator-
will inherits from-BaseDecorator-
.correct_name
method returning the@nameable
object'scorrect_name
method capitalized.-TrimmerDecorator-
will inherits from-BaseDecorator-
.correct_name
method returning the@nameable
object'scorrect_name
method trimmed unless the@nameable
object'scorrect_name
method length is less <= 10 characters.I have ✏️MODIFIED✏️ the succeeding *📂 folders and/or 📄** files
*📂 root/
**📄 README.md ✏️
*📂 lib/
**📄 person.rb ✏️
nameable
.correct_name
returning the@name
attribute.Thank you for taking the time to review this PR ⭐
If you require additional information or have any questions, don't hesitate to get in touch with me on Slack as Arturo (Arthur) Emanuel Guerra Iturres. I'll be happy to help you out. 🎯