Skip to content

Commit

Permalink
Added som yard documentation to the duck typing example
Browse files Browse the repository at this point in the history
  • Loading branch information
peter committed Aug 15, 2011
1 parent 2f10f94 commit d308b86
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
doc
.yardoc
Binary file modified Slides.key
Binary file not shown.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
- Explain attr_accessor
- for file in $(find lib -iname '*.rb'); do ruby -Ilib $file; done
- Enumerating strings with String#enum_for(:each_char|:each_byte|:each_line)
- Change from Rdoc to Yard
- Document duck_typing.rb with Yard
16 changes: 10 additions & 6 deletions lib/duck_typing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ def off
end

class Thermostat
# Here we should document the protocol that we expect
# the furnace object to conform to. Note that we could add assertions
# in the code here (by using respond_to?) to try to ensure that the furnace object has
# the methods that we expect. In practice though, such assertions would add little value.
# Creates a new Thermostat object
#
# @param [#on, #off] furnace on/off device that the thermostat will control
def initialize(furnace)
# Note that we could add assertions
# in the code here (by using respond_to?) to try to ensure that the furnace object has
# the methods that we expect. In practice though, such assertions would probably
# add little value.
@furnace = furnace
end

Expand Down Expand Up @@ -79,8 +82,9 @@ def run
# possibly more efficient way to transport the response. The Body commonly is an
# Array of Strings, the application instance itself, or a File-like object."
#
# Note how the Rack protocol is fairly strict and well specified and yet allows for a
# lot of flexibility in what classes and objects you use.
# Note how the Rack protocol is strict and well specified. The protocol is also quite
# narrow and it helps minimize the dependency between the webserver and the application.
# The protocol thus allows for a lot of flexibility in what classes and objects you use.
#
# Here is an example of a simple Rack application.

Expand Down
2 changes: 2 additions & 0 deletions resources.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Freiburg Course
* {Duck Typing in Practice (1 of 2)}[http://blog.rubybestpractices.com/posts/gregory/046-issue-14-duck-typing.html]
* {Duck Typing in Practice (2 of 2)}[http://blog.rubybestpractices.com/posts/gregory/047-issue-15-duck-typing-2.html]

* {What's Missing from TomDoc}[http://gnuu.org/2010/05/12/whats-missing-from-tomdoc]

* {Ruby: to_s vs. to_str}[http://briancarper.net/blog/98/]

Interviews with Matz
Expand Down

0 comments on commit d308b86

Please sign in to comment.