[#319096] n-dimensional array in Ruby — Christian <stadeschuldt@...>
Hi,
[#319104] Indexed arrays, delete_if, and performance — Jason Leong <jason@...>
Dear all,
On 01.11.2008 07:11, Jason Leong wrote:
> You can make that a tad more efficient by doing
On 01.11.2008 21:21, Jason Leong wrote:
[#319108] Iterator objects and lazy evaluation — Yuh-Ruey Chen <maian330@...>
Two questions:
On Nov 1, 1:16 pm, Brian Candler <b.cand...@pobox.com> wrote:
[#319117] Poor performance of Ruby 1.8.7 when installed with MacPorts — abc <arcadiorubiogarcia@...>
Hi,
Hi
nakatani katsumi wrote:
> Could someone explain this to to me. I checked the macports page a few
[#319139] Text Based RPG in Ruby — Ruairidh Mchardy <ruairidh82@...>
Hi all,
On Sat, 01 Nov 2008 14:38:08 -0400, Ruairidh Mchardy
Argh ok having problems with this. My code has just become very messy
[#319145] AJAX page.call not working — "Rajat Garg" <rajat79@...>
Hi Everyone,
[#319147] Another require question — Ed Hardy <asm.sol@...>
I've been learning Ruby for 2 weeks and of course I like it.
Ed Hardy wrote:
Yike. I 'knew it' but forgot, not at the surface of my mind/reading. I
[#319176] Ruby for Philosophers — Sebastian Torena <citizenkant@...>
Hi there,
> As far as I understand him he considers using Ruby to write a
Sebastian Torena wrote:
[#319196] ruby1.9: lazy versions of Enumerator#select and friends? — Brian Candler <b.candler@...>
I've been having a play with Enumerators in ruby 1.9, in particular
HI --
[#319208] check if valid hexadecimal code? — "Chealsea S." <youngliars@...>
How would you check if a string is a valid hexadecimal code?
On Sun, Nov 2, 2008 at 4:30 PM, Chealsea S. <youngliars@gmail.com> wrote:
[#319212] Trying to open a Lucene-built index with Ferret... — John Pritchard-williams <monojohnny@...>
But its wipes out the existing index and creates a new empty one - the
As far as i know, Ferret-built indexes are not binary-compatible with
[#319223] Ruby Tk on Windows Vista — Farmer Schlutzenberg <farmsal@...>
Hi,
[#319231] Using XPath: find last text node of each paragraph under the root node. — Diego <diego@...>
I want to trim trailing whitespace at the end of all XHTML paragraphs.
[#319239] Rake task for building latex? — Stefano Crocco <stefano.crocco@...>
Does anyone know whether there's a rake task to build latex files, including
Stefano Crocco wrote:
On Mon, 03 Nov 2008 14:18:39 +0100, Ron Fox <fox@nscl.msu.edu> wrote:
[#319242] recursion and variable scope level — Adam Akhtar <adamtemporary@...>
Hi i want to reverse a string and at the same time check if there are
[#319268] Help with iterating nested arrays — Mitko Kostov <mitko.kostov@...>
Hello, guys. I'm learning now Ruby and Shoes.
[#319273] Clean way of pausing a loop? — "Kyle Schmitt" <kyleaschmitt@...>
It's Monday and it's relatively early, so I apologize if this isn't
[#319278] Constructors — exiquio <exiquio@...>
The following is the beginning of a Java-esque new operator.
[#319285] Ruby Threads in Windows — Dave Wilson <davywilson@...>
Hi all. And thankyou in advance to anyone who responds.
Oh yes, and the new threads are running exe's e.g.
[#319319] Ruby's take on S.O.L.I.D. — Mike Lopke <reglopke@...>
I'm curious about everyone's take on Bob Martin's S.O.L.I.D. design
Mike Lopke wrote:
On Nov 4, 5:45=A0pm, Mike Lopke <reglo...@cableone.net> wrote:
[#319325] Wrapping ruby into one directory — Cary Fitzhugh <cfitzhugh@...360.com>
Hello --
[#319329] JRuby 1.1.5 Released — Thomas Enebo <Thomas.Enebo@...>
The JRuby community is pleased to announce the release of JRuby 1.1.5!
FYI, the updated FFI support is feature-equivalent to the just-released
[#319335] replace spaces with commas? — John Griffiths <indiehead@...>
Been looking at the Acts As Taggable On Steriods plugin, by default it
RnJvbTogSm9obiBHcmlmZml0aHMgW21haWx0bzppbmRpZWhlYWRAZ21haWwuY29tXSANCiMgQHMg
thanks Pe単a, admittedly regular expressions have never been my strong
[#319344] How to send mail with High priority — Sandy <lu.xiandong@...>
Hi all
[#319357] Socket Progamming - Beginner questions — Gin Mendi <gin18em@...>
Hi,
[#319358] Conditional overriding of operators — Daniel Vartanov <daniel.vartanov@...>
Hello!
[#319362] How to print an array with floating point numbers? — thiel <schang@...>
Hi,
[#319397] remote gem install doesn't work anymore — Forex Forex <trading@...>
hello,
[#319401] Combination of numbers in an array that add up to x — Hae Lee <hae.lee.subscription@...>
Objective: Find list of values in an array that adds up to a specific
Hae Lee wrote:
Axel Etzold wrote:
Hae Lee wrote:
Hae Lee wrote:
Giampiero Zanchi wrote:
[#319404] Showing a spinner ? — Aldric Giacomoni <aldric@...>
How do I show a spinner on the command line interface when a ruby script
Aldric Giacomoni wrote:
[#319418] Trying to Use "request_pty" Channel Never Closes — Nathan Halterman <scoobycoder@...>
I'm trying to interact with a RF Terminal application. But each time I
OOOOOkaaaaay. :)
Thanks Hugh,
[#319440] What would you like to know about JRuby? — Charles Oliver Nutter <charles.nutter@...>
Tom Enebo and I are putting together our JRuby presentation for
On Tue, Nov 4, 2008 at 8:51 PM, Charles Oliver Nutter
Oh, sorry. Rubyconf is over, I have not looked at the date of the
[#319450] Can I sell my RubyConf ticket? — Pat Maddox <pergesu@...>
Unfortunately I can't make it this year...I saw that there is a waiting
[#319456] ParseTree 3.0.2 Released — Ryan Davis <ryand-ruby@...>
[#319465] irb and ruby giving different results — Nit Khair <sentinel.2001@...>
in IRB,
Nit Khair wrote:
[#319474] replace values in hash — Jason Lillywhite <jason.lillywhite@...>
how would I iterate over a hash, such as
[#319494] what's wrong about this chomp code? — Zhenning Guan <g.zhen.ning@...>
when I was running this code
[#319503] String comparisions and counting — Stuart Clarke <stuart.clarke1986@...>
I have an array full of strings which represent a date ID. The array
[#319532] What's the Best Way to Mimic an HTTP Request? — Daniel Miessler <daniel@...>
I'm trying to write a tool that will take a domain as an argument and
On Wed, Nov 5, 2008 at 10:24 AM, Daniel Miessler <daniel@dmiessler.com> wrote:
Thanks, much, Michael. Unfortunately I'm not quite tracking on why that
[#319546] Ruby has a Face that it wears on its feet — "Jayson Williams" <williams.jayson@...>
In my opinion, Ruby's official face should be Shoes. Shoes gives Ruby
On Wed, Nov 5, 2008 at 11:17 AM, Jayson Williams
How about a melding of the two?
Jayson Williams wrote:
Kyle Hunter wrote:
[#319560] Garbage collector segmentation fault — Henrik Zagerholm <henke@...>
Hello list,
[#319576] how to quickly find a string towards the end of a large io object — bwv549 <jtprince@...>
How do I scan starting at the end of a big io object to find a string
[#319581] DRb + SSH — "Saji N. Hameed" <saji@...21.net>
Dear Gurus,
Saji N. Hameed wrote:
[#319598] Redefine while — Emil Sandin <esandin@...>
Hi, is there an easy way to redefine 'while'. I have a class that uses a
On Thu, Nov 6, 2008 at 10:00 AM, Emil Sandin <esandin@gmail.com> wrote:
[#319622] Finding gaps in a sorted sequence — Pete Hodgson <phodgson@...>
Hi Folks,
[#319641] FasterCVS Question/Problem — Eric Marthinsen <emarthinsen@...>
Hello-
[#319676] segmentation fault with ld-2.6.so — "Martin J. Brown, Jr." <mjbjr@...>
Suddenly, all my ruby apps, even the most basic, are seg faulting.
[#319686] Tips for Ruby Sprint — Edgardo Hames <ehames@...>
Hi guys,
[#319688] array.equal? — Nick Bhanji <nickbh@...4u.ca>
Hello All,
2008/11/7 Nick Bhanji <nickbh@weassemble4u.ca>:
[#319696] named scope lambda string substitution problem — jdwy <jdwyah@...>
Sorry for a cross post with rails, but I think this may be more of a
[#319698] Rails book wanted for non Ruby programmer — "Aaron Gray" <ang.usenet@...>
Hi,
"Hugh Sasse" <hgs@dmu.ac.uk> wrote in message
2008/11/7 Aaron Gray <ang.usenet@gmail.com>:
[#319702] Sudoku Generator (#182) — Matthew Moss <matt@...>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
[#319745] *** Amazing Bra Deflects Gunshot **** — rapidshareboobs1@...
Bra Saves womans life as deflects bullet !!!!
[#319748] Problem with "gem cleanup" on OS X 10.5 — Kenneth McDonald <kenneth.m.mcdonald@...>
When I try to execute 'sudo gem cleanup' on OS X 10.5, I get the
[#319760] un 1.0.0 Released — Ryan Davis <ryand-ruby@...>
[#319769] implementing mvc - using observer pattern - beginner to OOP — Adam Akhtar <adamtemporary@...>
Hi I started making a simple command line todo list application as a way
Hi thanks for the replies. I looked into MVC and i think its proably
[#319770] what's easiest way to compare a Float & BigDecimal (i.e. like a equals mechanism) — "Greg Hauptmann" <greg.hauptmann.ruby@...>
Hi,
Greg Hauptmann wrote:
On Nov 8, 8:26=A0am, Greg Hauptmann <greg.hauptmann.r...@gmail.com>
[#319777] is there a gem command to open up the rdoc for a particular gem in the default browser at the index page??? — "Greg Hauptmann" <greg.hauptmann.ruby@...>
Hi,
[#319812] Transliteration problems — "Axel Etzold" <AEtzold@...>
Dear all,
[#319835] Moving large amount of files, 1.750.000+ — Sebastian Newstream <abeansits@...>
Hello fellow Rubyists!
On 09.11.2008 18:04, Sebastian Newstream wrote:
On Sunday 09 November 2008 01:12 pm, Robert Klemme wrote:
On Sunday 09 November 2008 01:35 pm, Randy Kramer wrote:
Randy Kramer wrote:
* Sebastian Newstream <abeansits@gmail.com> [2008-11-10 17:11:08 +0900]:
First of all, thanks for your quick answer!
[#319840] shared-0.4.2 — ara howard <ara.t.howard@...>
[#319841] Require and symbolic links — Zouplaz <user@...>
Hi, thanks to the Shebang my /usr/local/somewhere/over/the/rainbow.rb
[#319856] design advice for newbie — John Goetz <goetz.john@...>
Hello,
[#319861] Notepad++ (no debug output, using XP) — Ed Hardy <asm.sol@...>
Notepad++ seems to be a great editor for Ruby, in XP Windows. However,
On Nov 19, 9:59=A0am, Ed Hardy <asm....@excite.com> wrote:
You may also want to try Ruby in Steel. I haven't tried it (I require
[#319876] how to find self class name inside self difinition ? — Thani Ararsu <thaniyarasu@...>
module Aa
[#319893] Watir: links with similar text in a page. How to access? — Mandeep Baruah <mbaruah@...>
Hi All,
[#319902] Problem with object methods? — Carter Davis <theshakrah@...>
I recently made an object for a game I'm making. It uses the constructor
Okay, I made an example.
I made all the changes to the test app and ran it, and here's what it
Hi --
[#319937] Look up objects by object_id — exiquio <exiquio@...>
So ruby objects have an object_id. What is the intended purpose of
[#319949] Comparing variable to multiple values — Greg Lazarev <russianbandit@...>
I'm wondering if there's a better way to do this in ruby:
[#319981] What is that method called? — David Trasbo <davidtrasbo@...>
I need the method that has the ability to turn a long string like this:
Hi David - just done this in Agile Development
[#319996] testing for ruby 1.9 in extension code — Alex Fenton <alex@...>
Hi
[#320023] Need script for the following problem — "Sita Rami Reddy" <sitaramireddy@...>
Hi,
[#320024] how to collect all the href links in a single page to a log file — "Sita Rami Reddy" <sitaramireddy@...>
I have a web which consists of multiple links with different colors. I want
[#320027] Advanced arrays — Stuart Clarke <stuart.clarke1986@...>
Hi all,
[#320038] unexpected return (LocalJumpError) — Kyung won Cheon <kdream95@...>
def a
[#320047] check a checkbox — Erika <geagneske83@...>
Hi,
[#320057] Convert text string i.e 'Peter' into integer ID — Justus Ohlhaver <ohlhaver@...>
Hello,
Justus Ohlhaver <ohlhaver@gmail.com> wrote:
[#320062] Can't get output from MiniTest — "David A. Black" <dblack@...>
Hi --
Hi,
Hi --
[#320083] Ruby Sub Regular Expression — Dave Roberts <dave.a.roberts@...>
Hello! I have a string: "Hello - 1 - World"
[#320101] Issue with block and getting to local variables — Tarek Other <cashew250@...>
Ok I'm new to ruby and want to do the following, I want to define a
On 12.11.2008 21:31, Tarek Other wrote:
Robert Klemme wrote:
On Wed, Nov 12, 2008 at 3:43 PM, Tarek Other <cashew250@yahoo.com> wrote:
Todd Benson wrote:
[#320103] Need tutoring on using a path environment variable — dkmd_nielsen <donn@...>
I don't know what to do. I have an environment variable, PW_PATH,
Let's provide more information. The contents of pw_path include this:
On Nov 12, 2008, at 6:22 PM, dkmd_nielsen wrote:
[#320111] Matching — Shandy Nantz <shandybleu@...>
I am trying to parse out some characters from a string and I am having
> I am trying to parse out some characters from a string and I am having
[#320125] nokogiri 1.0.5 Released — Aaron Patterson <aaron@...>
nokogiri version 1.0.5 has been released!
[#320131] Re: Regular expression for matching spaced letters needed — Jan Fischer <janfischer@...>
Sorry, wanted it here.
[#320135] '#' characters are breaking my regexp — Max Williams <toastkid.williams@...>
I'm trying to build a regexp that includes music notes, eg Bb or C#.
Max,
[#320161] Getting the comments(RDoc/ri) while running — Vassilis Rizopoulos <damphyr@...>
The problem:
It's a little open-ended ... I use Netbeans as my IDE when I write code,
[#320179] Mechanize Select List Help Needed — Cs Webgrl <cschaller@...>
Hello.
[#320181] Active Directory access - not just users, but computers too — Aldric Giacomoni <aldric@...>
Most Active Directory access really just goes through LDAP and I don't
On Thu, Nov 13, 2008 at 6:02 PM, Aldric Giacomoni <aldric@trevoke.net> wrote:
brabuhr@gmail.com wrote:
[#320200] One-Click Ruby Installer project stopped? — Claus Folke Brobak <cfb@...>
Hi,
[#320202] Highline - question with multiple choices — szimek <szimek@...>
Hi,
On Nov 14, 2008, at 4:23 AM, szimek wrote:
On 14 Lis, 14:52, James Gray <ja...@grayproductions.net> wrote:
On Nov 15, 2008, at 7:18 AM, szimek wrote:
Hello all, I'm new here and i have a problem...
On Dec 30, 2008, at 5:57 AM, Tomasz Krakowski wrote:
On Jan 5, 2009, at 1:17 AM, Tomasz Krakowski wrote:
[#320213] Unit Conversion (#183) — Matthew Moss <matt@...>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Given the conversation about "cheating", and what I know about the
> Anyway, cheating or not, I hope this proves helpful to anyone
On Fri, 14 Nov 2008 14:20:42 -0500, Matthew Moss wrote:
On Nov 15, 2008, at 8:07 PM, Ken Bloom wrote:
> For what it's worth, I always invited people to submit whatever they
> Agreed. I said it was cheating, but I didn't say "don't cheat." :D
> If your main issue is that you think "cheat" implies dishonesty, then
I just wanted to submit my first Ruby-quiz solution ever - but I was
[#320224] Ruby Mendicant Post-Mortem — "Gregory Brown" <gregory.t.brown@...>
Hi folks,
[#320229] Finding and writing to specified area in a text file — Ryan Mckenzie <ryan@...>
Hello,
In all of my research online, the only way that I've found to do it is
[#320232] Overriding methods in a class using a mixin — "James Coglan" <jcoglan@...>
Hi list,
[#320242] web framework for Ruby 1.9 — "Stefan Lang" <perfectly.normal.hacker@...>
I'm looking for a web framework that:
[#320251] KirbyBase, Table Default Values not being assigned — Adam Akhtar <adamtemporary@...>
Hi Ive been using KirbyBase and got it up and working and been fine with
im still banging my head against a wall on this one. I have no idea what
[#320253] rake finds & runs task, but doesn't show in --tasks list — "Hugh J. Devlin" <hdevlin@...>
hi, rake & ruby-talk newbie, a boy's 1st rake task, lib/tasks/load.rake:
[#320261] how to call operator as function — Vladimir Fekete <fekete@...>
Hi *,
[#320280] IO#lineno= doesn't work the way I expected — Chad Perrin <perrin@...>
I'm working on something that operates on each line of a file
Chad Perrin wrote:
On Sun, Nov 16, 2008 at 02:27:45AM +0900, Tim Hunter wrote:
On Sat, Nov 15, 2008 at 2:08 PM, Chad Perrin <perrin@apotheon.com> wrote:
On Sat, Nov 15, 2008 at 2:54 PM, Michael Guterl <mguterl@gmail.com> wrote:
On Sun, Nov 16, 2008 at 04:54:01AM +0900, Michael Guterl wrote:
Chad Perrin wrote:
On Sun, Nov 16, 2008 at 05:42:18AM +0900, Tim Hunter wrote:
hi chad!
On 15.11.2008 20:51, Michael Guterl wrote:
On Sun, Nov 16, 2008 at 08:36:50PM +0900, Robert Klemme wrote:
2008/11/16 Chad Perrin <perrin@apotheon.com>:
[#320307] erbook 4.0.0 (was previously named Gerbil) — Suraj Kurapati <snk@...>
erbook : write books and documents in eRuby
Hi Suraj,
[#320310] erb & action_view outside rails — David Lewis <djlewis@...>
I'm using erb as a templating package to generate html files -- not in
[#320317] dynamically create a hash of a objects variables values — Adam Akhtar <adamtemporary@...>
Tried my best to make this title as informative as possible but its
[#320319] when will the ruby 2.0 be released? — Rockydd <rockyac@...>
guys, I didn't find the schedule in the official site.
[#320335] gsub and reg expressions — Stuart Clarke <stuart.clarke1986@...>
I am having a few problems getting gsub to work with my regular
Stuart Clarke wrote:
The regular expression needs to be in array otherwise I recover
[#320359] Why does tmail stop my CGI script form working? — Chad Perrin <perrin@...>
I decided to try TMail for the back end of a new contact page on a
On Mon, Nov 17, 2008 at 01:16:25PM +0900, Ryan Davis wrote:
On Mon, Nov 17, 2008 at 01:45:05PM +0900, Chad Perrin wrote:
Unable to get tmail working properly on my shared hosting account, I
Why not try mailfactory if you're just sending e-mail? If it's just
On Tue, Nov 18, 2008 at 01:20:16AM +0900, Jeremy McAnally wrote:
On Nov 17, 2008, at 11:38 AM, Chad Perrin wrote:
On Tue, Nov 18, 2008 at 03:45:37AM +0900, James Gray wrote:
[#320370] How can I overload a method in Ruby — Zhao Yi <youhaodeyi@...>
This is my class definition:
there is no overloading, only overriding.
Einar Magn炭s Boson wrote:
RnJvbTogWmhhbyBZaSBbbWFpbHRvOnlvdWhhb2RleWlAZ21haWwuY29tXSANCiMgb2sgSSB1bmRl
Pe単a, Botp wrote:
RnJvbTogWmhhbyBZaSBbbWFpbHRvOnlvdWhhb2RleWlAZ21haWwuY29tXSANCiMgZGVmIGJ1aWxk
[#320375] Tread on eggs.. Using metaprogramming to set a variable name? — Aldric Giacomoni <aldric@...>
Something like ..
[#320388] Problems passing parameters into XSLT — Peter Hickman <peter@...>
I'm having some problems passing parameters into XSLT with ruby. The
[#320393] = 1 whee! — Mike Austin <"mike[nospam]"@...>
:) Just curious as to why Ruby automatically increases an array's size when
[#320400] Ruby equivalent to `find . -perm -g+rw -ls` — Bil Kleb <Bil.Kleb@...>
Hi,
[#320417] How to extract links of a particular class type — "Sita Rami Reddy" <sitaramireddy@...>
I have a web page which has n number of links.
On 2008.11.17., at 19:17, Sita Rami Reddy wrote:
My program need to do the following
require 'rubygems'
Thanq very much peter..it surved my purpose
> Thanq very much peter..it surved my purpose
[#320446] function to select only certain key/value pairs from hash? — Aryk Grosz <tennisbum2002@...>
Whenever Im coding I usually come across having to create a new hash
On Nov 17, 3:50=A0pm, Aryk Grosz <tennisbum2...@hotmail.com> wrote:
>>>
[#320458] let my custom defined class convert to string? — Jonathan Rochkind <rochkind@...>
Is there any way I can make it so my custom-defined class can be
Alle Tuesday 18 November 2008, Jonathan Rochkind ha scritto:
Thanks, that helps a lot, actually!
[#320461] Subclassing Hash to enforce value uniqueness ala key uniqueness. — Adam Gardner <adam.oddfellow@...>
First of all, hello to everyone. This is my first message to this list.
[#320482] I don't like specs, should I change my point of view ? — Zouplaz <user@...>
Hello, I'm not trolling. I don't like specs (RSpec) : everytime I had a
Peter Szinek wrote:
On Tue, 18 Nov 2008 08:49:51 -0500, James Gray wrote:
[#320487] ActiveRecord user — angico <angico@...>
Hi,
> Hi,
Em Ter, 2008-11-18 =C3=A0s 21:03 +0900, Peter Szinek escreveu:
[#320500] Should is the new Must? — Trans <transfire@...>
Why did 'should' become the going nomenclature of BDD framworks?
Trans wrote:
Hi,
On Nov 18, 6:09=A0am, Trans <transf...@gmail.com> wrote:
[#320504] Active Directory and Ruby — Bruno Sousa <brgsousa@...>
Hi everyone,
[#320513] selected field assignment — Bil Kleb <Bil.Kleb@...>
Hi,
[#320547] Library for writing ODF files — "Thiago Arrais" <thiago.arrais@...>
Last week I needed to generate a report in the format of an ODF spreadsheet and
[#320553] Syntax question from a newbie to Ruby — David Spitzer <davidspitzer@...>
I am just learning Ruby and I can not seem to see why the first example
David Spitzer wrote:
John W Kennedy wrote:
David Spitzer wrote:
On 18.11.2008 23:56, David Spitzer wrote:
[#320561] Ever heared of XRuby before? — "Robert Dober" <robert.dober@...>
Hi all,
[#320566] ruby global regex question. — knohr <just_a_techie200x@...>
For the life of me, i can't figure out a ruby equivalent to perl's /g
[#320607] Is there a way to know what are the subclasses of a given class ? — "Sandro Paganotti" <sandro.paganotti@...>
Hello
[SOLVED]
In your above example, B is not subclass of A (B is not even defined,
> On 2008.11.19., at 10:10, Sandro Paganotti wrote:
[#320609] "rescue Postgres::PGError" not working — Mandeep Baruah <mbaruah@...>
I am trying to rescue exceptions from a PostgreSQL query (see bellow
[#320611] JRuby on Android (from: What would you like to know about Jruby?) — Florian Gilcher <flo@...>
In "What would you like to know about Jruby?", Charles wrote:
Florian Gilcher wrote:
[#320613] RegExp problem — Jf Rejza <jfferriere@...>
Hy,
On Wed, Nov 19, 2008 at 10:55 AM, Jf Rejza <jfferriere@gmail.com> wrote:
Actually the correct regexp is:
On Wed, Nov 19, 2008 at 11:58 AM, Florian Gilcher <flo@andersground.net> wrote:
[#320622] Run a method in a Module — Mario Ruiz <mario@...>
Hi,
On Wed, Nov 19, 2008 at 11:40 AM, Mario Ruiz <mario@betware.com> wrote:
In my case is a little bit more complicated since the modules I'll use
[#320623] install a ruby library with it's .gem file — "Lyes Amazouz" <lyesjob@...>
Hello everybody!
[#320628] Not enough space error on windows — Ittay Dror <ittay.dror@...>
I get a 'Not enough space' error on windows. The disk has plenty of
[#320655] build hash by iterating — Jason Lillywhite <jason.lillywhite@...>
I am building a hash this way:
RnJvbTogSmFzb24gTGlsbHl3aGl0ZSBbbWFpbHRvOmphc29uLmxpbGx5d2hpdGVAZ21haWwuY29t
[#320665] Question about host, gethostbyname and getaddress — Vladimir Fekete <fekete@...>
Hi *,
On Wed, Nov 19, 2008 at 8:43 AM, Vladimir Fekete
Hello Alan,
On Wed, Nov 19, 2008 at 3:44 PM, Vladimir Fekete
Hello Alan,
From: Vladimir Fekete [mailto:fekete@melkor.dnp.fmph.uniba.sk]=20
[#320666] Error message, hide class name — Trans <transfire@...>
irb(main):005:0> class X
[#320694] how do you run ruby on windows — equinox <aditya15417@...>
Okay so I've downloaded the One-Click Ruby Installer for Windows and
[#320701] Survey Invitation : Ruby + GUI — Alex Fenton <alex@...>
Everyone's invited to take part in a short survey on using Ruby for GUI
[#320703] Ayuda con Ejercicio — Fernando Villafuerte <fernandovr@...>
Buenas Tardes a todos, primero quisiera informarles que yo no se nada de
[#320709] ANN: One-Click Ruby Installer 186-27 Release Candidate 2 — Luis Lavena <luislavena@...>
Hello Ruby for Windows users!
On Nov 20, 12:11=A0am, Bill Walton <bill.wal...@charter.net> wrote:
[#320713] RubyGems load path — Rodrigo Kochenburger <divoxx@...>
Hi Guys,
[#320717] Is there another method like .next? — "Michael W. Ryder" <_mwryder@...>
I was looking for a way to iterate through the ascii values and was
[#320725] BFS in ruby from a hash — equinox <aditya15417@...>
I want to do a breadth first search on a hash like below:
On Nov 20, 12:34=A0am, Robert Klemme <shortcut...@googlemail.com> wrote:
[#320734] Compiling Ruby Scripts (Ruby 1.9.x) — Sparky Mat <max@...>
I was wondering if it is possible to compile Ruby code for Ruby 1.9.x .
[#320759] search reg-exp for exact match — John Butler <johnnybutler7@...>
Hi,
[#320787] create a md5 / md5 passwd with a salt — Peter Woodsky <peter@...>
Hi list
[#320801] Sieve of Zakiya — jzakiya <jzakiya@...>
I've uploaded optimized upgraded versions of my SoZ prime generators,
On Thu, Nov 20, 2008 at 3:46 PM, jzakiya <jzakiya@mail.com> wrote:
[#320804] Hpricot scraping returns nil — Sergei Maertens <sergeimaertens@...>
Good evening
[#320810] Make RDoc escape inner element strings — Jose Fernandez <jose@...>
Is there a way to make RDoc use the html entities of stuff like:
[#320811] Found a ruby bug in the URI class, what do I do? — Ben Johnson <bjohnson@...>
I'm pretty sure this is a bug, and it seem so obvious that I'm thinking
Here's a workaround that fixes URI.parse.
On Sat, Dec 1, 2012 at 7:24 PM, David Madison <lists@ruby-forum.com> wrote:
tamouse mailing lists wrote in post #1087487:
On Sun, Dec 2, 2012 at 6:09 AM, David Madison <lists@ruby-forum.com> wrote:
[#320812] Weird conversion in IRB — Jeremy Woertink <jeremywoertink@...>
For some reason I have this line I am pasting from a text file into IRB,
[#320828] Can't install rails with gem — Joey Marino <joey.da3rd@...>
joey@lab:~$ gem --version
[#320839] jumpdates com - Free Online Dating — mckinneymbcrab@...
jumpdates com
[#320863] How to use include? on an array of objects — Fernando Perez <pedrolito@...>
I have the following array:
[#320877] BLT::Tabnotebook - tabnotebook.tcl not found — Philip Müller <me@...>
Hi,
From: Philip M=FCller <me@alienemperor.de>
Hi,
From: Philip M=FCller <me@alienemperor.de>
[#320886] append new line to textfile — Mmcolli00 Mom <mmc_collins@...>
I want to create a text file and append a new line to the text file
[#320893] libxml-ruby segfault on CentOS 5 (64 bit) — "Sebastian W." <swittenk@...>
Hello all,
[#320904] net/ssh for enable mode on cisco router — jackster the jackle <johnsheahan@...>
I am having trouble getting into enable mode and running commands on a
Not a direct answer, but I found the Net::SSH API too cumbersome to use
[#320908] Befunge (#184) — Matthew Moss <matt@...>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Hopefully the quiz isn't intimidating... It's a fairly simple language
On Mon, Nov 24, 2008 at 11:01 PM, Matthew Moss <matt@moss.name> wrote:
>
For those who want to play around I have extended Matthew's code with
Matthew Moss <matt@moss.name> wrote:
[#320912] Using Hpricot with HTML's — Rick Rick <ukbell@...>
I have been working on this program for class all day and am not getting
[#320918] wish list item: Method#to_proc — Roger Pack <rogerpack2005@...>
would this be useful/theoretically possible?
[#320920] Printing right arrow vs. a sane progressbar library — "Shot (Piotr Szotkowski)" <shot@...>
I want to track the progress of a set of (forkoff=E2=80=99d) processes in
[#320927] erbook 5.0.0 — Suraj Kurapati <snk@...>
erbook : write books and documents in eRuby
Interesting. I've been using AsciiDoc for DocBook creation. It's good
On Sun, Nov 23, 2008 at 11:47 AM, Dean Wampler <deanwampler@gmail.com> wrote:
[#320947] Storing Array in Hash — John Bentley <pluhveso@...>
I am having the most insane time with Ruby's Hash class.
[#320967] In Depth: attr_reader/writer/accessor — Matthew Madson <merlin009_50@...>
Can anyone explain exactly what happens when the interpreter interprets
[#320980] Ruby's new website — "Redd Vinylene" <reddvinylene@...>
Is it just me, or is Ruby's new website way too much? A jumble of bad
[#320981] Problem with sqlite3-ruby — Maciej Piechotka <uzytkownik2@...>
When I run:
> require reports (in irb,ar,sequel & co.) that it cannot load sqlite3.
[#320999] what's wrong with this method — equinox <aditya15417@...>
can someone tell me what's wrong with this method??
[#321006] Can you run a command line script with arguments, without typing 'ruby' first? — "Jayson Williams" <williams.jayson@...>
Hi All,
chmod a+x my_script (restrict permissions if you want)
I am using win os, so the shabang thing isn't an option for me. I put
On Mon, Nov 24, 2008 at 2:12 PM, Jayson Williams
On Mon, Nov 24, 2008 at 2:21 PM, Glen Holcomb <damnbigman@gmail.com> wrote:
The associations are correct. I reset them just to be sure though. I
On Mon, Nov 24, 2008 at 3:39 PM, Jayson Williams
2008/11/24 Kyle Schmitt <kyleaschmitt@gmail.com>:
Jayson Williams wrote:
Daniel,
Jayson Williams wrote:
Frustratingly, I got this working fine at work. I can type
Jayson Williams wrote:
Daniel Scher wrote:
[#321028] my attr_accessor — cibercitizen1 <CiberCitizen1@...>
I tried to
[#321037] Chris Pine tutorial assistance chapter 7 sort data without use of .sort method — jgheal@...
I'm learning to progam and came accross Chris Pine's Ruby Tutorial.
I am a beginner too;
[#321039] Good math/stats libraries for Ruby? — Kenneth McDonald <kenneth.m.mcdonald@...>
There seem to be lots of small stats/math libraries for Ruby, but none
> There seem to be lots of small stats/math libraries for Ruby, but none
Math/stats libraries still seem to need a bit of work compared to =20
On Tue, Nov 25, 2008 at 10:13, Joe W=F6lfel <joe@talkhouse.com> wrote:
* Cameron McBride <cameron.mcbride@gmail.com> [2008-11-26 09:39:48 +0900]:
[#321049] needed - ass kicking rubyist level 4.2 — ara howard <ara.t.howard@...>
ara howard <ara.t.howard@gmail.com> writes:
[#321069] no such file to load sqlite3 — Ben Johnson <bjohnson@...>
Ever since I updated my gems I have been getting the following error any
On Tue, Nov 25, 2008 at 10:38 AM, Ben Johnson <bjohnson@binarylogic.com> wrote:
Robert Dober wrote:
[#321073] Getting single char from string -- Simpler solution? — sa 125 <s_ayalon@...>
Hi -
Alle Tuesday 25 November 2008, sa 125 ha scritto:
[#321093] Getting browser country parameter in Ruby on Rails — CiriusMex <ciriusmex@...>
Hi folks ^^
[#321123] Begin else pattern question — "Mikel Lindsaar" <raasdnil@...>
What is the cleanest way of doing:
[#321129] How to use a passing argument(returned argument)? — =?EUC-KR?B?seggwdi/tQ==?= <jykim@...>
Hello, everyone !!!
[#321141] Ruby + FreeBSD = bandwidth killer? — Daniel Waite <rabbitblue@...>
This is a bizarre situation. I have a program that makes heavy use of
[#321149] Exclude members from YAML conversion? — Christian Kerth <christian.kerth@...>
Hi!
[#321160] attr_reader, default attribute value, and rdoc of attribute — dkmd_nielsen <donn@...>
What I want to do is create an attribute, allow it to have a default
[#321166] time to back peddle? (Ruby 1.8.7) — Trans <transfire@...>
I just updated my Ubuntu system and was a bit surprised to find:
On Wed, Nov 26, 2008 at 9:20 AM, Roger Pack <rogerpack2005@gmail.com> wrote:
> Though support was dropped for Ruby <= 1.8.5, 1.8.6 is still
On Nov 28, 3:36=A0am, Luc Heinrich <l...@honk-honk.com> wrote:
[#321175] ruby wish list item: more standard rescues — Roger Pack <rogerpack2005@...>
Currently in Ruby
[#321179] How to get a reference to a block (when no explicit block parameter is used?) — Kenneth McDonald <kenneth.m.mcdonald@...>
In a function, I can find out if a block was given using block_given?,
Kenneth McDonald <kenneth.m.mcdonald@sbcglobal.net> wrote:
Unfortunately, that produces a method that _requires_ a block--I want
[#321183] regexp problem — Chai Muang thong <thai4pental@...>
Hi,
[#321184] Class setter — Ves Pasian <keepitsimple222@...>
For the life of me I can figure out why the setter below returns "v" and
[#321212] To get time differnece in hours between two time values — Sijo Kg <sijo@...>
Hi
Sijo Kg wrote:
(Time.now - incidents.first.created_on) / 1.hour
[#321213] Read Database Metadata — Xd Ork <jorasmi.gagarin@...>
Hi All,
[#321215] Design suggestion for translations/mappings from xml — Brian Lonsdorf <brian@...>
Hi, i've got an xml file i'm parsing and creating objects from.
On Thu, Nov 27, 2008 at 7:00 AM, Brian Lonsdorf <brian@trnsfr.com> wrote:
> class Test
[#321216] Alternatives to ?\C-n, ?\M-a etc in ruby 1.9 — Nit Khair <sentinel.2001@...>
I need to make a rather important design in my 1.8 application, so i
RnJvbTogTml0IEtoYWlyIFttYWlsdG86c2VudGluZWwuMjAwMUBnbXguY29tXSANCiMgQnV0IHdo
[#321222] AutoIt: Regarging AutoIt usage with Firefox — Anukul Singhal <anukul.singhal@...>
Hi,
[#321223] unexpected error in time difference — "Heesob Park" <phasis@...>
Hi,
[#321230] creating a dynamic hash — Sijo Kg <sijo@...>
Hi
[#321246] Performance issues with large files -- ruby vs. python :) — sa 125 <s_ayalon@...>
Hi all -
>
I can't really put the code here since it's on the company's intranet. I
On Thu, Nov 27, 2008 at 9:39 AM, sa 125 <s_ayalon@hotmail.com> wrote:
brabuhr@gmail.com wrote:
On Thu, Nov 27, 2008 at 4:57 PM, Charles Oliver Nutter
On Thu, Nov 27, 2008 at 11:47 AM, Robert Dober <robert.dober@gmail.com> wrote:
[#321249] reg exp — Hai anh Le <lhanh@...>
Hi every body. I'm a newbie in Ruby and have problem with reg exp.
[#321264] Shebang! line not recognized in OS X Leopard?? — Johnnie Lieske <generic@...>
Hi
Johnnie Lieske wrote:
[#321271] Ruby's duck typing — "stephan.zimmer" <stephan.zimmer@...>
I would like to represent certain data by a list; to this end I let
[#321284] Noob: Code review my first tutorial homework assignment? — "Brian A." <judobrian+ruby-forum@...>
Hello!
On Thu, Nov 27, 2008 at 8:46 PM, Brian A.
[#321286] private #initialize — Yossef Mendelssohn <ymendel@...>
My apologies if this has been discussed before, but I couldn't find
[#321287] Programming Noob Chris Pine Tutorial sorting without use of array.sort method — whisperjim <jgheal@...>
I'm working through the following tutorial http://pine.fm/LearnToProgram/
On Thu, Nov 27, 2008 at 3:30 PM, whisperjim <jgheal@googlemail.com> wrote:
[#321288] Maximum number of files on a disk ? — "Axel Etzold" <AEtzold@...>
Dear all,
[#321297] eRuby/erb outside of Rails — Jonny Noog <jonnynoog@...>
Hello,
Try the free tool TudbcJRubyServlet
Why would you use this rather than Warbler (for example)?
Dick Davies wrote:
I appreciate the further suggestions and comments. Thanks very much. :)
[#321328] Rest-client posting multipart to rails 2 — "e deleflie" <edeleflie@...>
Hi all,
[#321353] Removing ^M character from text — John Victor <john@...>
I have some text that I just realized is screwing everything up because
Hi John,
On Fri, Nov 28, 2008 at 8:57 PM, John Victor <john@sflistdb.com> wrote:
[#321373] Desktop Application — Warren Dulnuan <rr3800@...>
Total noob on Ruby, didnt start yet but i'm planning to learn the
Warren Dulnuan wrote:
Warren Dulnuan wrote:
I made this application, which might be interesting but also very big
It's really hard shifting from pirated windows products to free open source,
[#321382] problem in Hash formatted output — jazzez ravi <jazzezravi@...>
Hi All,
[#321387] best gui toolkit — Warren Dulnuan <rr3800@...>
What is the best GUI toolkit for Ruby?
On Sun, Nov 30, 2008 at 02:26:15AM +0900, Vladimir Fekete wrote:
> It's also kind of onerous in terms of licensing, unless you just *really*
I've always thought Tk has been vastly underrated. It's worth it for
Warren Dulnuan wrote:
[#321400] Most used pwd in ruby — Sak Na rede <sak@...>
Hi all!
[#321405] rmagick and circles — "shawn bright" <nephish@...>
Hey there all,
[#321419] Avoid trucate column at printing table — Marc Pou <marc.pou@...>
Hi,
[#321421] Anyone scraping dynamic AJAX sites? — Becca Girl <cschall@...>
Hello.
On Sat, Nov 29, 2008 at 6:25 PM, Becca Girl <cschall@yahoo.com> wrote:
Just for completeness sake: scRUBYt! (since 0.4.05) is using FireWatir
[#321426] TCP Server — Sergio Aristizábal <bakkhoz@...>
Hi, i'm going to code a game server, i'm new in ruby an would
On 30 Nov 2008, at 02:00, Sergio Aristiz=E1bal wrote:
[#321427] Ruby Tk and X/Y coordinates — Johnny Johnnybgood <jarek123@...>
Hi everyone,
[#321428] Enumerable#select used to return actual values — Mike Austin <"mike[nospam]"@...>
I'm pretty sure select used to use the actual value of the called block,
On 30.11.2008 04:46, Mike Austin wrote:
On Sun, Nov 30, 2008 at 8:54 AM, Robert Klemme
Hi --
On Sun, Nov 30, 2008 at 11:13 AM, David A. Black <dblack@rubypal.com> wrote:
On Nov 30, 2008, at 4:26 AM, Robert Dober wrote:
Hi --
Hi,
On Nov 29, 10:46=A0pm, Mike Austin <"mike[nospam]"@mike-austin.com>
Hi,
[#321452] Aaron Bedra@Relevance Inc fraudulently claiming ownership of BSD licensed code -- how to protect? — "Rudi Cilibrasi" <cilibrar@...>
Hi everybody,
[#321453] Some benchmarks with MinGW, JRuby, MSVC... — Joao Pedrosa <joaopedrosa@...>
So, I have managed to build several different versions of Ruby to
[#321454] Help me understand how this block works? — "Brian A." <judobrian+ruby-forum@...>
Hello -
Re: Befunge (#184)
Here is my solution. It's not a revolutionary implementation, but I
had an emphasis on readability and testing. I believe it correctly
runs all the example programs from the Befunge-93 site that the C
reference implementation does.
While debugging I had a "C interpreter mode" which did a few things
slightly differently such as division and mod with negative numbers to
match the behaviour of the reference implementation. I eventually
removed it for clarity since it didn't gain much, other than
accounting for those differences.
For example, the following program will output -1 when run with the C
implementation and -2 with a standard Ruby implementation. Solutions
to Ruby Quiz #85 have some methods which provide C-like division and
mod.
3-2/.@
I couldn't find a simple solution for single character input, so it
goes without. Thus for programs like namegame.bf you have to hit enter
between each character.
Spec file is below the source. Thanks for the interesting quiz.
Jeff Dallien
http://jeff.dallien.net/
------- befunge.rb
#!/usr/bin/env ruby
# Befunge-93 interpreter for Ruby Quiz #184
# Jeff Dallien (jeff@dallien.net)
#
class Stack
attr_reader :stack
def initialize
@stack = []
end
def pop
return 0 if @stack.empty?
@stack.pop
end
def push(value)
@stack.push(value)
end
def swap!
first = pop
second = pop
push(first)
push(second)
end
def dup!
top = pop
push(top)
push(top)
end
end
class Instruction
attr_reader :value
def initialize(value)
@value = value
end
# digits 0-9
def value_for_stack?
(@value[0] >= 48 && @value[0] <= 57)
end
# " (double quote) toggles string mode
def string_mode_toggle?
(34 == @value[0])
end
end
class ProgramCounter
attr_reader :x
attr_reader :y
attr_accessor :direction
def initialize
@x = 0
@y = 0
@direction = :right
end
def move!
send("move_#{@direction}!")
end
private
def move_right!
@x = (@x + 1) % 80
end
def move_left!
@x = (@x - 1) % 80
end
def move_down!
@y = (@y + 1) % 25
end
def move_up!
@y = (@y - 1) % 25
end
end
class BefungeProgram
def initialize
@program = []
end
def load_from_file(filename)
File.open(filename) do |f|
25.times do
add_program_line(f.gets.to_s)
end
end
end
def [](index)
@program[index]
end
def load_from_string_array(program_strings)
25.times do |index|
add_program_line(program_strings[index].to_s)
end
end
private
def add_program_line(line)
padded_line = line.chomp[0..80].ljust(80)
@program << padded_line.split('').map { |c| c[0] }
end
end
class Befunger
INSTRUCTION_TABLE = { '@' => :exit,
' ' => :blank,
'\\' => :swap,
':' => :dup,
'$' => :pop,
',' => :output_ascii,
'.' => :output_int,
'+' => :add,
'-' => :subtract,
'*' => :multiply,
'/' => :divide,
'%' => :mod,
'!' => :not,
'`' => :greater,
'>' => :pc_right,
'<' => :pc_left,
'^' => :pc_up,
'v' => :pc_down,
'?' => :pc_random,
'_' => :horizontal_if,
'|' => :vertical_if,
'g' => :get,
'p' => :put,
'&' => :input_value,
'~' => :input_character,
'#' => :bridge,
'"' => :toggle_string_mode
}
def initialize(program)
@program = program
@pc = ProgramCounter.new
@stack = Stack.new
@exit_called = false
@string_mode = false
end
def run
until @exit_called
execute_instruction
@pc.move!
end
end
private
# used so that output can be captured during testing
def output(value)
print value
STDOUT.flush
end
def read_instruction
Instruction.new(@program[@pc.y][@pc.x].chr)
end
def execute_instruction
instruction = read_instruction
if @string_mode && !instruction.string_mode_toggle?
@stack.push(instruction.value[0])
elsif instruction.value_for_stack?
@stack.push(instruction.value.to_i)
else
begin
send(INSTRUCTION_TABLE[instruction.value])
rescue TypeError, NoMethodError
raise "Unknown instruction: #{instruction.inspect}"
end
end
end
def exit
@exit_called = true
end
def blank
end
def swap
@stack.swap!
end
def dup
@stack.dup!
end
def pop
@stack.pop
end
def output_ascii
value = @stack.pop
output value.chr
end
def output_int
value = @stack.pop
output "#{value.to_i} "
end
def generic_math_instruction(operation)
rhs = @stack.pop
lhs = @stack.pop
result = lhs.send(operation, rhs)
@stack.push(result)
end
def add
generic_math_instruction('+')
end
def subtract
generic_math_instruction('-')
end
def divide
generic_math_instruction('/')
end
def mod
generic_math_instruction('%')
end
def multiply
generic_math_instruction('*')
end
def not
value = @stack.pop
result = (value == 0) ? 1 : 0
@stack.push(result)
end
def greater
rhs = @stack.pop
lhs = @stack.pop
result = (lhs > rhs) ? 1 : 0
@stack.push(result)
end
def pc_right
@pc.direction = :right
end
def pc_left
@pc.direction = :left
end
def pc_up
@pc.direction = :up
end
def pc_down
@pc.direction = :down
end
def pc_random
directions = [:right, :left, :up, :down]
@pc.direction = directions[rand(4)]
end
def horizontal_if
value = @stack.pop
@pc.direction = (value == 0) ? :right : :left
end
def vertical_if
value = @stack.pop
@pc.direction = (value == 0) ? :down : :up
end
def get
y = @stack.pop
x = @stack.pop
@stack.push(@program[y][x])
end
def put
y = @stack.pop
x = @stack.pop
@program[y][x] = @stack.pop
end
def input_value
input = $stdin.gets.to_i
@stack.push(input)
end
def input_character
input_char = $stdin.gets[0]
@stack.push(input_char)
end
def bridge
@pc.move!
end
def toggle_string_mode
@string_mode = !@string_mode
end
end
if $0 == __FILE__
if ARGV[0]
program = BefungeProgram.new
program.load_from_file(ARGV[0])
befunger = Befunger.new(program)
befunger.run
else
puts "Usage: ruby befunge.rb program.bf"
end
end
-------- befunge_spec.rb
require 'befunge'
describe Stack, "popping a value" do
before :each do
@it = Stack.new
end
it "should return a zero when attempting to pop from an empty stack"
do
@it.pop.should == 0
end
end
describe Befunger, "processing instructions" do
before :each do
@output = ''
@stack = Stack.new
@pc = ProgramCounter.new
@program = BefungeProgram.new
ProgramCounter.should_receive(:new).and_return(@pc)
Stack.should_receive(:new).and_return(@stack)
end
def run_program(program_strings)
@program.load_from_string_array(program_strings)
processor = Befunger.new(@program)
processor.should_receive(:output).any_number_of_times { |o|
@output << o }
processor.run
end
describe "blank instruction" do
before :each do
run_program([" @",
"111@",
"@@@@"])
end
it "should not add any value the stack" do
@stack.pop.should == 0
end
it "should not change the program counter direction" do
@pc.direction.should == :right
end
end
describe "an unknown instruction" do
it "should raise an error" do
lambda { run_program(["=@"]) }.should raise_error(/Unknown
instruction/)
end
end
describe "add instruction" do
before :each do
run_program(["12+@"])
end
it "should put the result of the addition on the stack" do
@stack.pop.should == 3
end
end
describe "substract instruction" do
describe "with a positive result" do
before :each do
run_program(["65-@"])
end
it "should put the correct result on the stack" do
@stack.pop.should == 1
end
end
describe "with a negative result" do
before :each do
run_program(["56-@"])
end
it "should put the correct result on the stack" do
@stack.pop.should == -1
end
end
end
describe "multiplication instruction" do
before :each do
run_program(["55*@"])
end
it "should put the correct result on the stack" do
@stack.pop.should == 25
end
end
describe "mod instruction" do
describe "calculating with positive numbers" do
before :each do
run_program(["52%@"])
end
it "should put the correct value on the stack" do
@stack.pop.should == 1
end
end
describe "calculating with a negative number" do
before :each do
run_program(["1-2*3%@"])
end
it "should put the correct value on the stack" do
@stack.pop.should == 1
end
end
end
describe "division instruction" do
describe "calculating with positive numbers" do
before :each do
run_program(["93/@"])
end
it "should put the correct value on the stack" do
@stack.pop.should == 3
end
end
describe "calculating with negative numbers" do
before :each do
run_program(["3-2/@"])
end
it "should put the correct negative value on the stack" do
@stack.pop.should == -2
end
end
end
describe "swap instruction" do
before :each do
run_program(["123\\@"])
end
it "should swap the two top values of the stack" do
@stack.pop.should == 2
@stack.pop.should == 3
end
it "should not change the anything below the top two values" do
@stack.pop
@stack.pop
@stack.pop.should == 1
end
end
describe "duplication instruction" do
before :each do
run_program(["1:@"])
end
it "should put two copies of the value on the stack" do
@stack.pop.should == 1
@stack.pop.should == 1
end
end
describe "pop instruction" do
before :each do
run_program(["123$@"])
end
it "should remove a value from the stack" do
@stack.pop.should == 2
@stack.pop.should == 1
end
it "should not output anything" do
@output.should == ''
end
end
describe "not instruction" do
describe "with a 0 on the top of the stack" do
before :each do
run_program(["0!@"])
end
it "should put a 1 on top of the stack" do
@stack.pop.should == 1
end
end
describe "with a non-zero value on the top of the stack" do
before :each do
run_program(["1!@"])
end
it "should put a 0 on top of the stack" do
@stack.pop.should == 0
end
end
end
describe "greater instruction" do
describe "with the larger value placed on the stack first" do
before :each do
run_program(["52`@"])
end
it "should place a 1 on the top of the stack" do
@stack.pop.should == 1
end
it "should remove the compared values from the stack" do
@stack.pop
@stack.pop.should == 0
end
end
describe "with the smaller value placed on the stack first" do
before :each do
run_program(["38`@"])
end
it "should put a 0 on the top of the stack" do
@stack.pop.should == 0
end
end
describe "comparing the same value" do
before :each do
run_program(["44`@"])
end
it "should place a 0 on the top of the stack" do
@stack.pop.should == 0
end
end
end
describe "bridge instruction" do
before :each do
run_program(["123#...@"])
end
it "should skip the next instruction" do
@output.should == "3 2 "
end
it "should leave remaining values on the stack" do
@stack.pop.should == 1
end
end
describe "ASCII output instruction" do
before :each do
run_program(["665+*1-,@"])
end
it "should output the ASCII character of the value on the top of
the stack" do
@output.should == "A"
end
end
describe "integer output instruction" do
before :each do
run_program(["665+*1-.@"])
end
it "should output the integer on the top of the stack, followed by
a space" do
@output.should == "65 "
end
end
describe "string mode" do
before :each do
run_program(["\"Ab\"@"])
end
it "should place the ASCII values on the stack" do
@stack.pop.should == 98
@stack.pop.should == 65
end
end
describe "get instruction" do
describe "getting a value from within the given program" do
before :each do
run_program(["11g@",
" * "])
end
it "should get the value from the program and put it on the
stack" do
@stack.pop.should == '*'[0]
end
end
describe "getting a value outside the given program but in the
program space" do
before :each do
run_program(["88g@"])
end
it "should put the ASCII value of the space character (32) on
the stack" do
@stack.pop.should == 32
end
end
describe "attempting to get a value outside the 80x25 program
space" do
it "should raise an error" do
lambda { run_program(["066*g@"]) }.should raise_error
end
end
end
describe "put instruction" do
describe "within the 80x25 program space" do
before :each do
run_program(["522p@"])
end
it "should put the correct value inside the program space" do
@program[2][2].should == 5
end
end
describe "outside the 80x25 program space" do
it "should raise an error" do
lambda { run_program(["1188*p@"]) }.should raise_error
end
end
end
describe "horizontal if instruction" do
def horizontal_if_program(stack_value)
run_program(["#{stack_value} v @ ",
'@,,,,"left"_"thgir",,,,, @ ',
' @ '])
end
describe "with a zero on top of the stack" do
before :each do
horizontal_if_program('0')
end
it "should move the program counter to the right" do
@output.should == "right"
end
end
describe "with a non-zero value on top of the stack" do
before :each do
horizontal_if_program('4')
end
it "should move the program counter to the left" do
@output.should == "left"
end
end
end
describe "vertical if instruction" do
def vertical_if_program(stack_value)
run_program(["#{stack_value} |@",
' 5 ',
' @ ',
' 4 '])
end
describe "with a zero on top of the stack" do
before :each do
vertical_if_program('0')
end
it "should move the program counter down" do
@stack.pop.should == 5
end
end
describe "with a non-zero value on top of the stack" do
before :each do
vertical_if_program('2')
end
it "should move the program counter up" do
@stack.pop.should == 4
end
end
end
describe "controlling the program counter direction" do
describe "to the up direction" do
before :each do
run_program([" ^@",
" @",
" 7"])
end
it "should set the program counter direction to :up" do
@pc.direction.should == :up
end
it "should move upwards and loop to the bottom of the program"
do
@stack.pop.should == 7
end
end
describe "to the down direction" do
before :each do
run_program(["v8@",
" @ ",
">v@"])
end
it "should set the program counter direction to :down" do
@pc.direction.should == :down
end
it "should move downwards and loop to the top of the program" do
@stack.pop.should == 8
end
end
describe "to the left direction" do
before :each do
run_program(["<@5"])
end
it "should set the program counter direction to :left" do
@pc.direction.should == :left
end
it "should move left and loop to the right side of the program"
do
@stack.pop.should == 5
end
end
describe "to the right direction" do
describe "as the default direction" do
before :each do
run_program([" 1@"])
end
it "should set the program counter direction to :right" do
@pc.direction.should == :right
end
it "should move right when a program starts" do
@stack.pop.should == 1
end
end
describe "and reaching the edge of the program" do
before :each do
run_program([" v ",
"2@ > ",
" @ "])
end
it "should move right and loop to the left side of the
program" do
@stack.pop.should == 2
end
end
end
describe "in a random direction" do
before :each do
srand(3) # force predictable 'random' numbers, will always
choose :up first
run_program(["v@ ",
">?@",
" @ "])
end
it "should set the program counter direction based on the random
number" do
@pc.direction.should == :up
end
end
end
end