It is not your fault. Apple broke the Ruby scripting bridge with Mavericks (10.9) and never fixed it afterward. Thus, Ruby applications attempting to use Cocoa frameworks fail.
For Mavericks and Yosemite, there is an open source RubyCocoa v1.2.0 binary distribution that effectively patches the scripting bridge, allowing Hiroto's application to work again. It won't install on El Capitan, and must be compiled from source to install and work there. It won't even compile for macOS Sierra without some modifications to the source, and it is no longer supported as far as I can tell.
Hiroto may come along and rewrite this solution in Python Objective-C.
Here is a pure AppleScript solution that may prove useful for you, and is not based on Hiroto's work.
-- capture.applescript
--
-- enter screen coordinates for capture, and silently produces png with name
-- "Screen Shot yyyy-dd-mm at hh.mm.ss AM/PM".png
-- Version 1
-- VikingOSX, Nov. 8, 2016, Apple Support Communities
use scripting additions
set outdest to POSIX path of (path to desktop as text)
set msg to "Enter your start, and end coordinates as:" & return & ¬
"start-x,start-y,end-x,end-y" & return & "(e.g. 257,222,123,94)"
-- get the display size
tell application "Finder"
set {missing value, missing value, swidth, sheight} to get bounds of window of desktop
end tell
set screen_coord to text returned of (display dialogmsgdefault answer "")
set {TID, AppleScript'stext item delimiters} to {AppleScript'stext item delimiters, ","}
set mycoords to text items of screen_coord
set AppleScript'stext item delimiters to TID
-- validate that provided coordinates are within display boundaries
considering numeric strings
repeat with apoint in mycoords
if apoint > swidth or apoint > sheight then
display alert "Coordinate choices are outside screen size: w: " & swidth & " h: " & sheight
return
end if
end repeat
end considering
set dateStr to do shell script "date \"+%F at %H.%M.%S %p\""
set outfile to (outdest & "Screen Shot " & dateStr & ".png")'s quoted form
-- Add the -P option if you want the screen shot opened in Preview too
do shell script "/usr/sbin/screencapture -R " & screen_coord & space & outfile
return