Created
September 4, 2014 06:35
-
-
Save styrmis/420946e05621269ca93e to your computer and use it in GitHub Desktop.
Embedding code blocks in Leanpub aside/warning/tip blocks
This file contains 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
Example using both an embedded code block (with language explicitly specified), and inline code. | |
T> When a Ruby object is printed or otherwise asked to represent itself as a | |
string, the `to_s` ('to string') method of that object is called. So for our | |
managed object what we want to do is define a `to_s` method which displays our | |
task attributes. Add this method to `app/task.rb`: | |
T> | |
{lang="ruby"} | |
def to_s | |
"Priority: #{self.priority} " + | |
"Completed: #{self.completed} " + | |
"Description: '#{self.task_description}'" | |
end | |
T> | |
T> `Task` records will be shown in the console in a more informative form: | |
T> | |
T> `=> [Priority: 5 Completed: 0 Description: 'Go to the supermarket']` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment