Skip to content

Instantly share code, notes, and snippets.

View emiltin's full-sized avatar

Emil Tin emiltin

  • City of Copenhagen
  • Denmark
  • 08:57 (UTC +02:00)
View GitHub Profile
class CrazyNum
def div? v,b
"#{v%b==0 ? '' : 'not '}dividable by #{b}"
end
def examine v
puts "The value #{v} is #{div? v,3} and is #{div? v,5}."
end
class Integer
def divisable? v,b
"#{v%b==0 ? '' : 'not '}dividable by #{b}"
end
def show_divisors
puts "The value #{self} is #{divisable? self,3} and is #{divisable? self,5}."
end
class Integer
def divisable? v,b
"#{v%b==0 ? '' : 'not '}dividable by #{b}"
end
def show_divisors *a
info = a.map { |n| "is #{divisable? self,n}" }.join ' and '
puts "The value #{self} #{info}."
end
class Integer
def show_divisors *a
info = a.map { |n| "is #{'not ' unless self%n==0}dividable by #{n}" }.join ' and '
puts "The value #{self} #{info}."
end
end
1.upto(10) { |x| x.show_divisors 3,5 }
1.upto(10) { |x| x.show_divisors 2,4,7 }
~/MacRuby-trunk$ rake jobs=2 --trace
. . .
/usr/bin/gcc -dynamic -bundle -undefined suppress -flat_namespace -arch i386 -arch x86_64 -o socket.bundle socket.o -L. -L../.. -arch i386 -arch x86_64 -lmacruby
cd ext/zlib && ../../miniruby -I../.. -I../../lib -r rbconfig -e "RbConfig::CONFIG['libdir'] = '../..'; require './extconf.rb'"
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for kind of operating system... Unix
creating Makefile
cd ext/zlib && /usr/bin/make top_srcdir=../.. ruby="../../miniruby -I../.. -I../../lib" extout=../../.ext hdrdir=../../include arch_hdrdir=../../include libdir=../..
~$ macruby -rubygems /Users/emiltin/Desktop/1011.rb
== Sinatra/1.1.0 has taken the stage on 4567 for development with backup from WEBrick
[2010-12-04 21:01:21] INFO WEBrick 1.3.1
[2010-12-04 21:01:21] INFO ruby 1.9.2 (2008-06-03) [universal-darwin10.0]
[2010-12-04 21:01:21] INFO WEBrick::HTTPServer#start: pid=20352 port=4567
127.0.0.1 - - [04/Dec/2010 21:01:38] "GET / HTTP/1.1" 404 409 0.4013
activate.adobe.com - - [04/Dec/2010:21:01:37 CET] "GET / HTTP/1.1" 404 409
- -> /
127.0.0.1 - - [04/Dec/2010 21:01:38] "GET /__sinatra__/404.png HTTP/1.1" 304 - 0.2487
activate.adobe.com - - [04/Dec/2010:21:01:38 CET] "GET /__sinatra__/404.png HTTP/1.1" 304 0
cd ext/zlib && ../../miniruby -I../.. -I../../lib -r rbconfig -e "RbConfig::CONFIG['libdir'] = '../..'; require './extconf.rb'"
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for kind of operating system... Unix
creating Makefile
cd ext/zlib && /usr/bin/make top_srcdir=../.. ruby="../../miniruby -I../.. -I../../lib" extout=../../.ext hdrdir=../../include arch_hdrdir=../../include libdir=../..
/usr/bin/gcc -I. -I../../include -I../../include/ruby/backward -I../../include -I. -I../.. -DHAVE_ZLIB_H -DOS_CODE=OS_UNIX -fno-common -arch i386 -arch x86_64 -fexceptions -fno-common -pipe -O3 -g -Wall -arch i386 -arch x86_64 -o zlib.o -c zlib.c
/usr/bin/gcc -dynamic -bundle -undefined suppress -flat_namespace -arch i386 -arch x86_64 -o zlib.bundle zlib.o -L. -L../.. -arch i386 -arch x86_64 -lmacruby -lz
rake aborted!
Command failed with status (2): [cd ext/iconv && /usr/bin/make top_srcdir=....]
~/MacRuby-trunk$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
~/MacRuby-trunk$ rake jobs=2 --trace
[numerous lines..........]
cd ext/zlib && ../../miniruby -I../.. -I../../lib -r rbconfig -e "RbConfig::CONFIG['libdir'] = '../..'; require './extconf.rb'"
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for kind of operating system... Unix
creating Makefile
.....
SHA_H -DHAVE_SYS_CDEFS_H -DHAVE_INTTYPES_H -DHAVE_UNISTD_H -fno-common -arch i386 -arch x86_64 -fexceptions -fno-common -pipe -O3 -g -Wall -arch i386 -arch x86_64 -o sha1ossl.o -c sha1ossl.c
/usr/bin/gcc -dynamic -bundle -undefined suppress -flat_namespace -arch i386 -arch x86_64 -o sha1.bundle sha1init.o sha1ossl.o -L. -L../../.. -arch i386 -arch x86_64 -lmacruby -lcrypto
cd ext/digest/sha2 && ../../../miniruby -I../../.. -I../../../lib -r rbconfig -e "RbConfig::CONFIG['libdir'] = '../../..'; require './extconf.rb'"
checking for sys/cdefs.h... yes
checking for inttypes.h... yes
checking for unistd.h... yes
checking for uint64_t in defs.h with -DHAVE_CONFIG_H -DHAVE_SYS_CDEFS_H -DHAVE_INTTYPES_H -DHAVE_UNISTD_H... yes
creating Makefile
cd ext/digest/sha2 && /usr/bin/make top_srcdir=../../.. ruby="../../../miniruby -I../../.. -I../../../lib" extout=../../../.ext hdrdir=../../../include arch_hdrdir=../../../include libdir=../../..
have_func:: checking for iconv() in iconv.h... -------------------- no
"/usr/bin/gcc -o conftest -I/Library/Frameworks/MacRuby.framework/Versions/0.8/usr/include/ruby-1.9.2/universal-darwin10.0 -I/Library/Frameworks/MacRuby.framework/Versions/0.8/usr/include/ruby-1.9.2/ruby/backward -I/Library/Frameworks/MacRuby.framework/Versions/0.8/usr/include/ruby-1.9.2 -I. -arch i386 -arch x86_64 -fexceptions -fno-common -pipe -O3 -g -Wall conftest.c -L. -L../.. -arch i386 -arch x86_64 -arch i386 -arch x86_64 -lmacruby "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */