I am new with ruby… and now I’ve started to learn patterns. Is this a pattern or just a library?
require 'builder'
xml = Builder::XMLMarkup.new(:target => @output, :ident => 1)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, that’s not a pattern, you just instantiated a class.
Design Patterns are a generic topic in programming. There are some patterns specific to ruby. There are books and lists of all the patterns — just search internet for them.
An example of a generic design pattern: Producer/Consumer Pattern, where a consumer populates a queue with data, while a consumer asynchronously polls from the queue and processes the data (just off the top of my head). It’s useful when you have 2 loops running at different speeds.
A ruby specific pattern: Overriding method_missing in a class you make to give it dynamic function names. I think this a pattern I see a lot in ruby libraries.