Skip to content

Commit

Permalink
More Docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkdoor committed Jan 25, 2012
1 parent 8d88807 commit d73ef16
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
6 changes: 6 additions & 0 deletions bin/fancy
Expand Up @@ -4,6 +4,12 @@
base = File.dirname(__FILE__)
require File.expand_path("../boot/fancy_ext", base)

class Object
define_method("__AFTER__BOOTSTRAP__:") do |block|
block.call
end
end

# Use the bootstrapping code loader.
require File.expand_path("../boot/load", base)

Expand Down
4 changes: 4 additions & 0 deletions boot/fancy_ext/object.rb
@@ -1,4 +1,8 @@
class Object
define_method("__AFTER__BOOTSTRAP__:") do |block|
nil
end

define_method("ruby:with_block:") do |method, block|
self.send(method, &block)
end
Expand Down
34 changes: 33 additions & 1 deletion lib/html.fy
@@ -1,4 +1,36 @@
class HTML {
"""
HTML generator class.
Example:
require: \"html\"
html = HTML new: @{
html: @{
head: @{ title: \"My Fancy Website\" }
body: @{
div: { id: \”main\” } with: \"Hello, Fancy World!\"
}
}
} . to_s
# html is now:
\"\"\"
<html>
<head>
<title>
My Fancy Website
</title>
</head>
<body>
<div id=\"main\">
Hello, Fancy World!
</div>
</body>
</html>
\"\"\"
"""

def initialize {
@buf = ""
@indent = 0
Expand All @@ -18,7 +50,7 @@ class HTML {
unless: (attrs empty?) do: {
@buf << " "
attrs each: |k v| {
@buf << k << "=" << (v inspect)
@buf << k << "=" << (v to_s inspect)
} in_between: {
@buf << " "
}
Expand Down
17 changes: 17 additions & 0 deletions lib/vars.fy
@@ -1,3 +1,20 @@
*stdin* = STDIN
*stdout* = STDOUT
*stderr* = STDERR

__AFTER__BOOTSTRAP__: {
*stdin* documentation: """
The Standard Input stream.
Can be rebound to any @IO@ stream via @Object#let:be:in:@.
"""

*stdout* documentation: """
The Standard Output stream.
Can be rebound to any @IO@ stream via @Object#let:be:in:@.
"""

*stderr* documentation: """
The Standard Error Output stream.
Can be rebound to any @IO@ stream via @Object#let:be:in:@.
"""
}

0 comments on commit d73ef16

Please sign in to comment.