From: Quintus Date: 2013-03-03T20:07:34+09:00 Subject: Re: Extending Ruby. Little help or guidance if you are willing! --Sig_/wplPFp4K1dQ1/1=zeaUIkE7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Am Sun, 3 Mar 2013 10:31:25 +0900 schrieb Cliff Rosson : > Hi Folk, Hi Cliff, > def display_segments(num, display, io, delay =3D 0.005) > # ... > sleep delay > # ... > end I doubt Ruby=E2=80=99s sleep is exact enough to sleep such a small delay of time, especially given the general Floating-Point precision problems. I=E2=80=99d suspect that your #sleep call is actually taking longer than you expect. > I think the logic in my C method would be the same as my ruby one. > The part where I run into trouble is converting values. For example I > can't figure out how to decide which pins to light by hash key. In > fact I can't even figure out how to get the hash keys... There are two great sources I use when writing C extensions for Ruby: * The official README.EXT by Matz: http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v2_0_0_0/README.EXT?view= =3Dmarkup * Rubinius=E2=80=99 ruby.h header file, because it=E2=80=99s way better doc= umented than Ruby=E2=80=99s: https://github.com/rubinius/rubinius/blob/master/vm/capi/19/include/ruby/= ruby.h For getting values out of hashes, you want rb_hash_aref(). Vale, Marvin --Sig_/wplPFp4K1dQ1/1=zeaUIkE7 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iQEcBAEBAgAGBQJRMzz/AAoJELh1XLHFkqhaS/MH/09p7XRICNBxUkhOFgu1fJ4F 4eAlDQh43Gr85RTMj2BRHDgE98PCIu3Ha4mQk5MzKYz1SmjETe3zpPiq/9/gTEmX 5NI6f9Iqb2Xs41C35uPj2u4TOXIy68a3kNigLZdYUwJwenbrIjThIaaa+68j1qmk FGfKCVSVmCe+tRckMd+YTJ39rxmpdJGNxqytKEzClNAaaXF2WFZ/nu2z/namPj/m lV/lfG3a+dWrNX3mTlZDucT+T3z2l/Pizlu2lteODsFR4wn6U/TskL6MOaohXBks ii6cN+15FuEeJCocDiHQJ9mZmoeGEHss6X66f+79wd4d3szX9TZdKSKy3Pn93jc= =czxp -----END PGP SIGNATURE----- --Sig_/wplPFp4K1dQ1/1=zeaUIkE7--