Created
March 28, 2012 00:59
-
-
Save steveclarke/2222587 to your computer and use it in GitHub Desktop.
Block Test for VotD
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 Votd | |
attr_reader :reference, :text, :version | |
def initialize | |
@reference = "John 3:16" | |
@text = "For God so loved the world..." | |
@version = "NIV" | |
end | |
def to_html | |
@custom_html ||= "<p>#{@text}</p><p>#{@reference}</p><p>#{@version}</p>" | |
end | |
def custom_html | |
@custom_html = yield(self) | |
self | |
end | |
end | |
votd = Votd.new | |
puts "Default HTML" | |
puts votd.to_html | |
votd.custom_html do |votd| | |
"<div class='custom'>#{votd.reference}: #{votd.text}</div>" | |
end | |
puts "Custom HTML" | |
puts votd.to_html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment