SWORD in Ruby
July 31st, 2007
On a number of occasions, I’ve played around with manipulating the text of the Bible in Ruby. Tonight, for the first time, I did it the correct and obvious way, and was successful.
require 'rubygems'
require 'inline'
class Bible
inline(:C) do |builder|
builder.include ''
builder.add_compile_flags '-x c++', '-lstdc++', '-I/opt/local/include/sword', '-L/opt/local/lib', '-lsword'
builder.prefix %{
using namespace sword;
}
builder.c %{
char * text(char * ref) {
SWMgr mgr = SWMgr();
SWModule *kjv = mgr.getModule("KJV");
kjv->setKey(ref);
return kjv->RenderText();
}
}
end
end
puts Bible.new.text("jn 3:16").gsub(/<[^>]*>/, '')
You need to sudo port install sword sword-bible-kjv first. This is going to be useful.

Sorry, comments are closed for this article.