Last active
September 27, 2018 12:48
-
-
Save astagi/2e109aa6cbc8db3abcc9e660227ab667 to your computer and use it in GitHub Desktop.
Try to use macro
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
module Ansa | |
private | |
# @!macro [attach] generate_get_news | |
# @method get_$1_news | |
# @!scope class | |
# @note This method is autogenerated | |
# Get news for "$1" category. | |
# @raise [Ansa::AnsaError] when errors occour fetching news | |
# @return [Array<Ansa::News>] all the news of category "$1". | |
def self.generate_get_news(category, url) | |
define_singleton_method("get_#{category}_news") do | |
get_news_by_url(url) | |
end | |
end | |
public | |
generate_get_news 'soccer', 'the_soccer_url.xml' | |
generate_get_news 'politics', 'the_politics_url.xml' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment