I was given the solution by Watson at the MacRuby-devel mailing list. I should have written my code like that:
range=Pointer.new(NSRange.type)
#though range=Pointer.new("{_NSRange=QQ}") would also work
then, as I had before
font=txtStor.attribute(NSFontAttributeName,atIndex:index,effectiveRange:range)
and if needed I could dereference the range by range[0]
.