require 'irb/completion'
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:PROMPT_MODE] = :SIMPLE
\# call ri from within irb
def ri(*names)
system(%{ri.bat #{names.map {|name| name.to_s}.join(" ")}})
end
require 'irb/completion'
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:PROMPT_MODE] = :SIMPLE
\# call ri from within irb
def ri(*names)
system(%{ri.bat #{names.map {|name| name.to_s}.join(" ")}})
end
Ruby on Rails is a big framework, with hundreds (thousands?) of methods and classes. Thanks to the clever folk at Nodeta, their new documentation app APIdock provides an easy-to-use search/browse interface to the whole of Rails documentation. To quote the site:
APIdock is a web app that provides a rich and usable interface for searching, perusing and improving the documentation of projects that are included in the app.
The site also provides documentation for Ruby and RSpec. Two really interesting features of the site are the versions bar graph and dynamic keyword search.
The versions bar graph along the top of each documentation page lets you "go back in time" to past versions of the documentation, by clicking on the version number. The green and red tabs indicate when and by how much the documentation changed for that version, which is handy when you're trying to figure out just when and in what way a particular method was changed or deprecated:
The dynamic keyword search displays a "find as you type" drop-down list from which you can select the relevant documentation page. A little pie graph icon, divided into five wedges, indicates by the number of filled-in wedges how much information is available for each item:
So for example there's a lot of information about the form_for helper, but very little about the apply_form_for_options! helper. If you get as lost in Rails as I do, or you're just wondering what is the difference between form_remote_for and remote_form_for (hint: the former is an alias for the latter).
Tried out Search_Ruby_documentation_v0.4.bsh, Jim Morris' version of a macro for searching Ruby documentation from jEdit. The macro depends on FastRI.
C:\USAFIPD\Tools\Reports>irb
>> n = "4^10^10^10^6^6^6^5^6^6^6^5^6^5^6^3"
=> "4^10^10^10^6^6^6^5^6^6^6^5^6^5^6^3"
>> eval(n.gsub("^","+"))
=> 100
>> puts "sum: " + eval(n.gsub("^","+")) + " cols: " + n.split("^").length
TypeError: can''t convert Fixnum into String
from (irb):3:in ''+''
from (irb):3
>> puts "sum: " + eval(n.gsub("^","+")).to_s + " cols: " + n.split("^").length.to_s
sum: 100 cols: 16
=> nil
>>
eval(n.gsub(...)) would add up the digits. Still, I didn't have to refer to the Pickaxe Book at all!#!/usr/bin/env ruby
require 'find'
files = {}
found = {}
# read root directory from command line
ARGV.each do |arg|
Find.find(arg) do |f|
if File.file?(f)
# accumulate the file names
files[f] = File.basename(f)
end
end
end
# count up the number of each file name
files.each_value do |base|
# Ruby doesn't allow this Perl idiom: found[base]++
found[base] = 0 if !found[base]
found[base] += 1
end
# print the path of each file found more than once,
# prepended with rm command commented out
found.each do |name,count|
if count > 1
files.each do |path,filename|
if name == filename
puts "# rm #{path}"
end
end
end
end