John Lam 1997 — 2026

Indigo and Ruby: great together (well sort of)

If you look at the code that I wrote to call flickr using Indigo, you’ll notice that the flickr API call accepts a string and returns a string. This makes it trivial for me to interop with Ruby:

require 'RubyShim'
require 'builder'
require 'builder/xmlmarkup'
require 'rexml/document'

reference_file 'flickrlib.dll'

include FlickrLib
include Builder
include REXML

f = Flickr.new('83293ff34e3ab3d9935018480190319f')
puts f.Call('<method>flickr.people.findByEmail</method>
             <find_email>jlam@iunknown.com</find_email>')

# or if you prefer
xml = Builder::XmlMarkup.new
xml.method     "flickr.people.findByEmail"
xml.find_email "jlam@iunknown.com"

d = Document.new(f.Call(xml.target!))
puts d.elements['//username'].text

I’m not all that happy with sending mal-formed XML as an in-parameter, but it was a quick and easy hack to get it up and running.

2 archived reader comments

Matt (2005-12-01)

Are you going to make your Ruby CLR bridge available for download at any point?

Pościel Wełniana (2006-10-22)

Looks tricky, but interesting indeed.