Skip to content

Instantly share code, notes, and snippets.

@steveclarke
Created March 28, 2012 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveclarke/2222587 to your computer and use it in GitHub Desktop.
Save steveclarke/2222587 to your computer and use it in GitHub Desktop.
Block Test for VotD
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