Dec
12
Syntax Highlighter
Hi, I'm testing a javascript based syntax highlighter for this blog. Let's see how it works:
#Ducktyping: Does it walk like a duck? Does it quack like a duck?
if arg1.responds_to? :capitalize
puts "Then '#{arg1.capitalize}' must be a string.\n"
else
if arg1.responds_to? :modulo && arg1.responds_to? :numerator
puts "Then '#{arg1.to_s}' must be an integer.\n"
else
if arg1.responds_to? :modulo && arg1.responds_to? :truncate
puts "Then '#{arg1.to_s}' must be a float.\n"
end
end
end
Whoops, guess not :( Anyone knows how to solve this issue?
Nice :) Actually I used this widget to make it work.
Update: I couldn't resist and I also implemented it in this wiki.
#Ducktyping: Does it walk like a duck? Does it quack like a duck?
if arg1.responds_to? :capitalize
puts "Then '#{arg1.capitalize}' must be a string.\n"
else
if arg1.responds_to? :modulo && arg1.responds_to? :numerator
puts "Then '#{arg1.to_s}' must be an integer.\n"
else
if arg1.responds_to? :modulo && arg1.responds_to? :truncate
puts "Then '#{arg1.to_s}' must be a float.\n"
end
end
end
Whoops, guess not :( Anyone knows how to solve this issue?
Nice :) Actually I used this widget to make it work.
Update: I couldn't resist and I also implemented it in this wiki.