Fix rubydoc.info generation: add newlines between fenced code blokcs to README.md
This commit is contained in:
parent
7644b2663e
commit
d5b0fc778e
|
@ -30,6 +30,7 @@ end
|
||||||
```
|
```
|
||||||
|
|
||||||
No problem, just define the method `with_array` like this:
|
No problem, just define the method `with_array` like this:
|
||||||
|
|
||||||
``` ruby
|
``` ruby
|
||||||
def with_array(arr=[], &block)
|
def with_array(arr=[], &block)
|
||||||
Docile.dsl_eval(arr, &block)
|
Docile.dsl_eval(arr, &block)
|
||||||
|
@ -43,6 +44,7 @@ Easy!
|
||||||
Mutating (changing) an Array instance is fine, but what usually makes a good DSL is a [Builder Pattern][2].
|
Mutating (changing) an Array instance is fine, but what usually makes a good DSL is a [Builder Pattern][2].
|
||||||
|
|
||||||
For example, let's say you want a DSL to specify how you want to build a Pizza:
|
For example, let's say you want a DSL to specify how you want to build a Pizza:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@sauce_level = :extra
|
@sauce_level = :extra
|
||||||
|
|
||||||
|
@ -55,6 +57,7 @@ end
|
||||||
```
|
```
|
||||||
|
|
||||||
And let's say we have a PizzaBuilder, which builds a Pizza like this:
|
And let's say we have a PizzaBuilder, which builds a Pizza like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
Pizza = Struct.new(:cheese, :pepperoni, :bacon, :sauce)
|
Pizza = Struct.new(:cheese, :pepperoni, :bacon, :sauce)
|
||||||
|
|
||||||
|
@ -89,6 +92,7 @@ It's just that easy!
|
||||||
Parameters can be passed to the DSL block.
|
Parameters can be passed to the DSL block.
|
||||||
|
|
||||||
Supposing you want to make some sort of cheap [Sinatra][3] knockoff:
|
Supposing you want to make some sort of cheap [Sinatra][3] knockoff:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
@last_request = nil
|
@last_request = nil
|
||||||
respond '/path' do |request|
|
respond '/path' do |request|
|
||||||
|
@ -106,6 +110,7 @@ end
|
||||||
```
|
```
|
||||||
|
|
||||||
You'd put together a dispatcher something like this:
|
You'd put together a dispatcher something like this:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
require 'singleton'
|
require 'singleton'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue