Skip to content

Instantly share code, notes, and snippets.

@styrmis
Created September 4, 2014 06:35
Show Gist options
  • Save styrmis/420946e05621269ca93e to your computer and use it in GitHub Desktop.
Save styrmis/420946e05621269ca93e to your computer and use it in GitHub Desktop.
Embedding code blocks in Leanpub aside/warning/tip blocks
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