[#365105] Synchronized Circular Buffer — Sam Dalton <mail@...>
I'm relatively new to Ruby, having switched from a PHP and Java
[#365112] Fast searching of large files — Stuart Clarke <stuart.clarke1986@...>
Hey all,
[#365147] Running a shell command from ruby — Steve Pauly <stevepauly@...>
I am experimenting with running bash commands from within ruby. The
[#365148] ANN: zozo 1.0.0 Released — Jeremy Evans <code@...>
= What?
[#365151] Handling File.open exceptions — Carl Jenkins <carljenkins@...>
I was reading the pick axe book (for 1.9 version of ruby) and on page
On 01.07.2010 22:24, Carl Jenkins wrote:
[#365153] synchronize a "mocked" clock in a distributed system — Chuck Remes <cremes.devlist@...>
I've been banging on a problem for a few days now and don't feel any closer to solving it. I'm hoping some of the big brains on the ruby ML can shed some light. Following are a few paragraphs with a brief system overview before I state the problem. I apologize in advance for this question being only tangentially related to Ruby the language. :)
On Thu, Jul 1, 2010 at 3:10 PM, Chuck Remes <cremes.devlist@mac.com> wrote:
Chuck Remes wrote:
On Mon, Jul 5, 2010 at 7:44 PM, William Rutiser <wruyahoo05@comcast.net> wrote:
On Jul 5, 2010, at 2:12 PM, Robert Dober wrote:
On Mon, Jul 5, 2010 at 2:06 PM, Chuck Remes <cremes.devlist@mac.com> wrote:
On Mon, Jul 5, 2010 at 3:15 PM, Chuck Remes <cremes.devlist@mac.com> wrote:
[#365181] FasterCSV - Merge CSV — Christian Smith <christian.essner@...>
I have 3 CSVs with the same content with say 10 rows. There is a slight
Christian Smith wrote:
[#365214] RubyGoLightly Progress Report — Eleanor McHugh <eleanor@...>
I seem to have been missing in action for the best part of six months so =
On Sat, Jul 3, 2010 at 4:27 AM, Eleanor McHugh
[#365216] redirect_to(user_contacts_path(@current_user)) error — Aashish Kiran <aashishkiran8@...>
Hi, I am getting exception with
[#365219] How to easily upgrade to new Ruby 1.9 patch level — Alex DeCaria <alex.decaria@...>
I currently have Ruby 1.9.1 p378 installed on Windows. If I want to
[#365230] name correspondence — Intransition <transfire@...>
The proposed Ruby Package Standard states:
[#365231] Permanent script hosting ? — Manu Cap <darksniper2003@...>
Hello,
[#365247] Garbage Collection on Windoze — Thierry Lambert <thyresias@...>
Minasan konbanha
> ObjectSpace.each_object(Test) { |o| puts o.inspect }
[#365260] speeding up "gem1.9 install" during development — "R.. Kumar 1.9.1 OSX" <sentinel1879@...>
During development, I keep running rake install. The following command
[#365262] File data extraction — Rolf Pedersen <rolfhsp@...>
Hi
[#365284] undefined local variable or method `code_words' for main:Ob — Abder-rahman Ali <abder.rahman.ali@...>
I have the problem:
[#365288] extending a core class cleanly [noobish alert] — Fearless Fool <r@...>
Assume I'd like to create a statistics package designed to work on
[#365297] Golf on CLI code — Intransition <transfire@...>
I have a registry (array) of CLI classes. Each class has a class
[#365301] RCR getch — Roger Pack <rogerpack2005@...>
It would be quite convenient to have a getch method in Ruby.
[#365309] MiniTest test case execution — George Thomas <george.thomas@...>
Hi,
[#365315] WTF? Case statement disfunctional? — Pieter Hugo <pieter@...>
Hi
On Tuesday 06 July 2010, Pieter Hugo wrote:
Hi guys
[#365320] Why am I not getting the expected output? — Abder-rahman Ali <abder.rahman.ali@...>
I have the following code: http://pastie.org/1032525, but always getting
On Tuesday 06 July 2010, Abder-rahman Ali wrote:
Stefano Crocco wrote:
Did you change the '===' operator maybe?
[#365351] best way to make .rb into an executable for linux? — David Ainley <wrinkliez@...>
I have a pretty basic .rb script that I would like to turn into an
On Tue, Jul 6, 2010 at 2:42 PM, David Ainley <wrinkliez@gmail.com> wrote:
I see. Well I could use that as a last resort I suppose, but won't the
On Tue, Jul 6, 2010 at 4:26 PM, David Ainley <wrinkliez@gmail.com> wrote:
[#365358] rubygarden? — Roger Pack <rogerpack2005@...>
Anybody know what happened to rubygarden.org?
[#365374] Hashes don't allow preceding commas by design? — Iain Barnett <iainspeed@...>
This is the output from irb that shows ruby 1.9.1 doesn't like hash =
It's not hashes it is the parser in general. When it parses a line (up to
On Wed, Jul 7, 2010 at 3:36 AM, Peter Hickman <
On 7 July 2010 10:15, Josh Cheek <josh.cheek@gmail.com> wrote:
On Wed, Jul 7, 2010 at 4:36 AM, Peter Hickman <
[#365386] Ruby switches — Kenneth <ken70r@...>
Let's say I have something like this
Kenneth wrote:
Hi, the point I was trying to make was sending a boolean method to the
[#365392] New, but this seems odd... — Andrew Wagner <wagner.andrew@...>
Ok, granted that I'm pretty new to ruby, but this seems odd to me:
[#365413] What is meant by those lines of code in this script? — Abder-rahman Ali <abder.rahman.ali@...>
I came across the following script from "Why's poignant guide to Ruby".
On Wed, Jul 7, 2010 at 5:48 PM, Abder-rahman Ali
Hi,
On Sun, Jul 11, 2010 at 5:26 PM, Abder-rahman Ali <
Colin Bartlett wrote:
[#365414] Symbols vs. variable — Abder-rahman Ali <abder.rahman.ali@...>
What is the main difference between using a symbol (begins with :), and
[#365430] ri and rdoc....like perldoc? — Derek Smith <derekbellnersmith@...>
Hi All,
On Wed, Jul 7, 2010 at 10:10 PM, Derek Smith
Xavier Noria wrote:
[#365448] Regular expressions, capture repeated groups — Iain Barnett <iainspeed@...>
I'm trying to emulate something I've done in .Net many moons ago, which =
[#365454] Standalone Ruby executable with GUI — Ralph Shnelvar <ralphs@...32.com>
I have been using Ruby in a Rails environment.
[#365474] Where can I find shoes? — Reece Machin <modtarget@...>
Hey. Just wondering if anybody knows where I can find Shoes? I've
[#365489] from functions to classes, where should I start? — salamond <jarodzz@...>
Guys, I'm not sure if this is the right place to ask questions like this.
Hi JaordZZ,
On 09.07.2010 19:11, Jay wrote:
[#365504] FIRST PROGRAMMING PROBLEM Array — Francisco Martinez <calabazag@...>
Hi...I'm trying to solve a very simple exercise but this is one of my
On Fri, Jul 9, 2010 at 1:22 PM, Francisco Martinez <calabazag@hotmail.es> w=
unknown wrote:
[#365513] what about allowing to specify, which end belongs to which start? — Jan Lelis <prog@...>
Hi Ruby mailing list,
On 09.07.2010 21:17, Ryan Davis wrote:
On 7/9/10, Jan Lelis <prog@janlelis.de> wrote:
On 10.07.2010 17:54, Caleb Clausen wrote:
On 7/11/10, Robert Klemme <shortcutter@googlemail.com> wrote:
On 11.07.2010 13:32, Caleb Clausen wrote:
On 7/11/10, Robert Klemme <shortcutter@googlemail.com> wrote:
2010/7/11 Caleb Clausen <vikkous@gmail.com>:
> [...] I question the balance of effort and benefit.
On Mon, Jul 12, 2010 at 12:59 PM, Jan Lelis <prog@janlelis.de> wrote:
> > def test
[#365527] if statements and case statements questions — John Crichton <a2533488@...>
I am fairly new to Ruby and programming and had a couple questions about
[#365550] how to convert it into utf-8? — Pen Ttt <myocean135@...>
in my linux comsole:
[#365556] sample ruby program to talk to an exchange server — Dani Dani <laguna53@...>
Hi, I'm looking for a sample programm to test the communication with an
Dani Dani wrote:
On Mon, Jul 12, 2010 at 10:44 AM, Dani Dani <laguna53@ymail.com> wrote:
[#365562] Basic Question: How do you check to see if gets is a number? — Adam Bourg <adam.bourg89@...>
I wrote a basic script that asks for your age then converts it into
On Sun, Jul 11, 2010 at 12:34 PM, Adam Bourg <adam.bourg89@gmail.com> wrote=
Rick Denatale wrote:
[#365570] How to pass a hash as a param to a method called through eval? — Alex Stahl <astahl@...5.com>
Hi Folks - I've got a data-driven app I'm building, and I'd like to be
On Sun, Jul 11, 2010 at 10:57 PM, Alex Stahl <astahl@hi5.com> wrote:
Thanks, but... tried that already and it fails without even calling the
On Sun, Jul 11, 2010 at 11:29 PM, Alex Stahl <astahl@hi5.com> wrote:
Just use 'puts' instead of 'eval' to see what's happening.
On Jul 11, 2:57=A0pm, Alex Stahl <ast...@hi5.com> wrote:
Thanks. You're actually the second response to suggest doing it that
On Mon, Jul 12, 2010 at 12:41 AM, Alex Stahl <astahl@hi5.com> wrote:
[#365600] How to create keybinds? — Erik Lindstahl <makire@...>
My Rubyknowledge is somewhat limited, so im in need of some help with
[#365601] Arrays and Hashes — Abder-rahman Ali <abder.rahman.ali@...>
In "Why's poignant guide to Ruby" it mentions the following:
[#365609] Adding cookies to my http client — Safas Khkjh <ryandewhurst@...>
Hi,
[#365614] Substitution — Abder-rahman Ali <abder.rahman.ali@...>
I have this part of code from "Why's poignant guide to Ruby" that is
What that says is use the gsub! method on the object pointed to by idea
Let me give an example I'm making similar to that, where I would like
I think my MAIN point is this.
[#365615] Try Ruby is back online. — andrew mcelroy <sophrinix@...>
Greetings,
On Mon, Jul 12, 2010 at 6:53 PM, andrew mcelroy <sophrinix@gmail.com> wrote:
On Mon, Jul 12, 2010 at 12:23 PM, Xavier Noria <fxn@hashref.com> wrote:
On Mon, Jul 12, 2010 at 7:43 PM, andrew mcelroy <sophrinix@gmail.com> wrote:
[#365642] regex to match similar strings — John Butler <johnnybutler7@...>
Hi,
[#365662] I'm trying to get the keys, but why values appear? — Abder-rahman Ali <abder.rahman.ali@...>
I'm trying to write a script that lists ONLY the keys in a hash as
[#365668] Why do I get undefined method? — Abder-Rahman Ali <abder.rahman.ali@...>
I'm trying to write a script such that when you enter a year, you get
[#365678] ruby & flash — Ce Vau <adi@...>
Hello there.
[#365679] Consuming a SOAP Service using Savon Gem — Saeed Bhuta <saeed.bhuta@...>
Hi,
[#365686] Errors in Ruby — Abder-Rahman Ali <abder.rahman.ali@...>
In the following sentence: The raise method is from the Kernel module.
[#365687] Ruby 1.9.2 float precision — Diogo Almeida <diogo.borges.almeida@...>
Hello,
2010/7/13 Diogo Almeida <diogo.borges.almeida@gmail.com>:
[#365697] Shouldn't this be called a global constant? — Abder-Rahman Ali <abder.rahman.ali@...>
In "why's poignant guide to Ruby" book, it mentioned that: $LOAD_PATH is
On Tue, Jul 13, 2010 at 2:42 PM, Abder-Rahman Ali
[#365721] Ruby garabage collector — Abder-Rahman Ali <abder.rahman.ali@...>
In the "Why's poignant guide to Ruby" book, it states the following:
The simplest way to think of it is if something falls out of scope.
James Harrison wrote:
Thanks a lot James for your clarification.
Thanks a lot James for your advice. Yes, think have to read more deeply
On Tue, Jul 13, 2010 at 11:24 AM, Abder-Rahman Ali
On 13-07-2010 17:30, Abder-Rahman Ali wrote:
[#365752] What does this do? — Abder-Rahman Ali <abder.rahman.ali@...>
I have this portion of code from "Why's poignant guide to Ruby" book.
On Tue, Jul 13, 2010 at 4:26 PM, Abder-Rahman Ali <
[#365764] How can I get the result of this equation — Abder-Rahman Ali <abder.rahman.ali@...>
I have written this a script like this:
[#365775] How to update Ruby >>> CentOS — Ehab Diab <admin@...>
Hello,
[#365776] Stdout as IO object — Jonathan Bale <webmaster@...>
Okay, real simple question, but somehow I am missing it in the API: how
[#365782] gets() -- Need to skip when no response after 20seconds — "Raveendran .P" <jazzezravi@...>
Code:
Raveendran .P wrote:
Hi,
Hi Park,
[#365799] I have some questions about this modified String class — Abder-Rahman Ali <abder.rahman.ali@...>
I have the following script that I just have only slight changes in the
[#365801] what's proble with ruby-mysql-prepare? — Pen Ttt <myocean135@...>
when i run p1 ,i can get something like:
[#365811] Modules in Ruby — Abder-Rahman Ali <abder.rahman.ali@...>
I have this script with slight change from "The Little Book Of Ruby":
And, a small thing here. Can we say that "Modules" in Ruby are like
[#365828] click a javascript dialog window in Firefox — Mario Ruiz <tcblues@...>
Hi,
On Wed, Jul 14, 2010 at 6:39 PM, Mario Ruiz <tcblues@gmail.com> wrote:
But the thing is... if you click first.. ff keeps waiting and doesn't
On Fri, Aug 13, 2010 at 1:53 PM, Mario Ruiz <tcblues@gmail.com> wrote:
So there is no way to click the buttons on a javascript window
On Fri, Aug 13, 2010 at 2:07 PM, Mario Ruiz <tcblues@gmail.com> wrote:
[#365837] Cpp Complier — Allan Davis <javaalley@...>
I am trying to figure out which would be the best C++ compiler to install on
On Wed, Jul 14, 2010 at 2:55 PM, Allan Davis <javaalley@gmail.com> wrote:
[#365844] Return nothing when looking outside the bounds of 2D array? — Shawn W_ <shawnw@...>
I have a 2D Array. I have written a method
On Jul 14, 3:56=A0pm, Shawn W_ <sha...@internode.on.net> wrote:
Thx. Don't quite understand that code. I tried plugging in some nils but
A better way to describe it.
I was going to suggest using the 'case' statement instead of all those =
Okay, just found out that...
On Fri, Jul 16, 2010 at 11:11 AM, Shawn W_ <shawnw@internode.on.net> wrote:
Martin DeMello wrote:
OK, let's try this from the top. {grin} Here's some fresh new code:
[#365847] Ruby best practice for "always on" app/service? — yermej <yermej@...>
I'm building an app that will essentially be a web service client. It
On Wed, Jul 14, 2010 at 11:10 PM, yermej <yermej@gmail.com> wrote:
[#365849] HighLine freezes when using wrap_at and page_at — LAMBEAU Bernard <blambeau@...>
Hi all,
[#365852] Ruby 1.9.1-p129 — Wesley Wong <wesley.mw.wong@...>
I was trying to install ruby 1.9.1-p129 through RVM and got this error
[#365863] what is the advantage is to use class methods over object me — Arun Kumar <jakheart001@...>
Hi All,
[#365879] Ruby for Windows Mobile (Win CE, CeGCC) — Maxim Sokolovsky <a.x.e.1@...>
Hi,
[#365889] Sending packets over TCP server — Zsdfhdfgasdf Gsfgsdgsdgsd <hikay_akira@...>
I'm making a TCP server in Ruby, and I still haven't figured out how I
Zsdfhdfgasdf Gsfgsdgsdgsd wrote:
[#365904] Ruby 1.9.1 Array#combination kinda lazy — Phrogz <phrogz@...>
C:\>type tmp.rb
[#365906] Triggernig the debugger — Ralph Shnelvar <ralphs@...32.com>
In Rails I can use the
[#365915] Setting configuration until end of parent bash session — Intransition <transfire@...>
Any advice on how a ruby script can set a config info that's per
[#365920] Triggering the debugger II — Ralph Shnelvar <ralphs@...32.com>
I'm still having trouble with the debugger and debugging
[#365937] help please with REXML — Ben Morse <cornflaik@...>
hello,
[#365949] Recurse through array of arrays — Iain Barnett <iainspeed@...>
Hi,
[#365972] Hpricot test for equivalence of two xml segments? — Xeno Campanoli / Eskimo North and Gmail <xeno.campanoli@...>
I'm looking through what documentation I can find for Hpricot (nokogirl wouldn't
On Sat, Jul 17, 2010 at 12:28 AM, Xeno Campanoli / Eskimo North and Gmail <
On 10-07-16 03:16 PM, Ammar Ali wrote:
On Fri, Jul 16, 2010 at 6:52 PM, Xeno Campanoli / Eskimo North and Gmail <
[#365988] client-side Ruby on iPad/iPhone? — Jeff Pritchard <jp@...>
I've seen jRuby and IronRuby, and really want to use them since i really
On Friday, July 16, 2010 10:35:17 pm Jeff Pritchard wrote:
On Sat, Jul 17, 2010 at 12:46 AM, David Masover <ninja@slaphack.com> wrote:
On Saturday, July 17, 2010 11:43:52 am Tony Arcieri wrote:
On Sat, Jul 17, 2010 at 9:41 PM, David Masover <ninja@slaphack.com> wrote:
On Sunday, July 18, 2010 09:30:37 pm Tony Arcieri wrote:
[#365994] Infinite Loop in Code -- Logic Error — James Rasmussen <jamesrasmus@...>
Hi all,
Hi --
[#365997] Driving irb from IO.popen — Jean-Julien Fleck <jeanjulien.fleck@...>
Hello,
[#366004] Instance eval in 1.8 and 1.9 — Gavin Sinclair <gsinclair@...>
Hi,
On Saturday 17 July 2010, Gavin Sinclair wrote:
>
[#366015] ruby abstraction — "James O'Brien" <jeob32@...>
Hi,
On Saturday, July 17, 2010 08:21:10 pm James O'Brien wrote:
On 07/18/2010 06:53 AM, David Masover wrote:
[#366041] The price of a modern list architecture? — Jacko <jackokring@...>
http://groups.google.co.uk/group/comp.lang.forth/browse_thread/thread/ef39e59023a8ae4c/9eb9f6b99139a5df#9eb9f6b99139a5df
[#366053] LoadError: no such file to load -- tk — Rich Leblanc <rl001@...>
I'm trying to install Ruby on a 64 bit Windows 7 machine following this
Roger Pack wrote:
On Mon, Jul 19, 2010 at 3:26 PM, Rich Leblanc <rl001@pacbell.net> wrote:
Eric Christopherson wrote:
Roger Pack wrote:
Rich Leblanc wrote:
Roger Pack wrote:
From: Rich Leblanc <rl001@pacbell.net>
Rich Leblanc wrote:
From: Rich Leblanc <rl001@pacbell.net>
Hidetoshi NAGAI wrote:
From: Rich Leblanc <rl001@pacbell.net>
On Wed, Jul 21, 2010 at 1:27 PM, Rich Leblanc <rl001@pacbell.net> wrote:
Roger Pack wrote:
[#366058] capture STDOUT data to a variable — Shaun Paul <kv.bijesh@...>
Hello
[#366077] REXML Input File Question — Mike Pe <mikep123@...>
Hi,
On 19.07.2010 21:13, Mike Pe wrote:
Robert Klemme wrote:
2010/7/24 Mike Pe <mikep123@gmail.com>:
[#366084] Error Compiling Ruby — Kota Weaver <kota.weaver@...>
Hello,
[#366091] how to judge web exists or not with open-uri? — Pen Ttt <myocean135@...>
would you mind to tell me how to fix it, to make the following program
[#366100] Editing a FAT/FAT32 Partition Table — Philip Wright <sulligogs@...>
Hi,
This may work for you.
Very fast. Thanks for the heads up.
[#366102] How to uninstall ruby on FreeBSD 8.0? — Wilson Wang <wilsonwang111@...>
Dear all,
[#366115] Count occurences of vars in array — Vitaliy Yanchuk <fuksito@...>
Hello, everyone.
Hello,
Jean-Julien Fleck, thanks.
2010/7/20 Vitaliy Yanchuk <fuksito@gmail.com>:
Jean-Julien Fleck wrote:
[#366118] File.basename — "James O'Brien" <jeob32@...>
File.open('myfile') do |f|
[#366119] Ruby Shoes tray icon? — MrZombie <mrzombie@...>
Hi all!
[#366152] Can't get ruby 1.9 to work after install on OSX — Musdev Musdev <devrubygem@...>
Hello
Joseph E. Savard wrote:
RVM is your best bet.. The work is already done for you through scripts and
Joseph E. Savard wrote:
Musdev,
Or you can always default to the Ruby you want to use.
[#366165] Friday Night at My House — John Barnette <jbarnette@...>
Attendees: Me, Aaron Patterson, Ben Bleything, Eric Hodel, Ryan Davis, =
[#366172] How to avoid black-windows using system() ? — Rémi Cools <remi@...>
Hi,
R辿mi Cools wrote:
Roger Pack wrote:
[#366187] File class documentation — "James O'Brien" <jeob32@...>
Hi,
anyone? :)
James O'Brien wrote:
[#366192] mechanzie submit fails at gmail login — Chugm 456789 <chugm456789@...>
Hallo everybody,
On Wed, Jul 21, 2010 at 6:12 AM, Chugm 456789 <chugm456789@googlemail.com>wrote:
thiago damasceno wrote:
On Thu, Jul 22, 2010 at 3:33 AM, Chugm 456789 <chugm456789@googlemail.com>wrote:
[#366193] How to check if x is a multiple of y — Tom Ha <tom999@...>
Hi there,
On Wed, Jul 21, 2010 at 12:12 PM, Tom Ha <tom999@gmx.net> wrote:
2010/7/21 Xavier Noria <fxn@hashref.com>:
[#366196] how to make "gem install rmagick" work? — Jian Lin <blueskybreeze@...>
I wanted to install rmagick on Win7 but it can't install:
[#366226] Text to Binary — Umm Whyshouldisay <kipthemudkip@...>
Hi! I'm new to the forums. I'm also a bit new to Ruby. I already know
On Thu, Jul 22, 2010 at 1:12 AM, Umm Whyshouldisay
> "some text".unpack('b*')
See String#unpack http://ruby-doc.org/core/classes/String.html#M000760
Alright, new question. How do you take each individual character and use
See String#[], String#split, String#match and a much more on String
Ricardo Panaggio wrote:
[#366234] Writing to file delay — Matt Triviski <matt.triviski@...>
Hello All,
Matt Triviski <matt.triviski@gmail.com> wrote:
[#366245] Enumerators and generators — Hal Fulton <rubyhacker@...>
Hi, all...
Hello Hal
[#366254] finding last line in a file — Ted Flethuseo <flethuseo@...>
Hi everyone,
Take a look at the doc for File.readline.
(2010/07/22 14:08), Urabe Shyouhei wrote:
On 07/22/2010 07:10 AM, Urabe Shyouhei wrote:
(2010/07/22 15:35), Robert Klemme wrote:
2010/7/22 Urabe Shyouhei <shyouhei@ruby-lang.org>:
(2010/07/22 22:06), Robert Klemme wrote:
[#366281] Two Question — Amir Ebrahimifard <amiref@...>
Hi everybody
[#366303] documentation from inside irb — Eugen Ciur <eugen@...>
Hi,
[#366319] Typical Ruby (non-rails) project structure. — Carl Jenkins <carljenkins@...>
What is/are the best-practice(s) for a Ruby project structure?
Carl Jenkins wrote:
On Thu, Jul 22, 2010 at 6:41 PM, Carl Jenkins <carljenkins@gmail.com> wrote:
[#366336] HowTo get ruby to report a sumbolic link? — James Byrne <byrnejb@...>
I am creating a series of symbolic links to target directories. I wish
[#366378] how to convert the string? — Pen Ttt <myocean135@...>
i want to convert a string "-34\n \302\240" into "-34"
On 07/23/2010 03:45 PM, Pen Ttt wrote:
irb(main):001:0> "-34\n \302\240".match(/\S+/).to_s
[#366401] rmagick for Ruby 1.8.6 won't work for Ruby 1.8.7? — winter heat <blueskybreeze@...>
if i install
[#366418] Ruby books designed especially for beginngers — Kaye Ng <sbstn26@...>
Hey experts, i need your advice.
[#366422] re-organize original text data then write in files — Junhui Liao <junhui.liao@...>
Dear all,
[#366430] Design Question — Mochi Mochigome <jbw+mochigome@...>
Hi guys,
[#366451] basic beginner help needed — Karl Halvorson <karl.halvorson@...>
I am new to Ruby and have been looking for some basic beginner help. I
[#366466] syntax — Raghu Maddali <raghu1216@...>
Hi all,
On Sun, Jul 25, 2010 at 5:23 AM, Raghu Maddali <raghu1216@yahoo.co.in>wrote:
I apologize for miscommunication.I know that Ruby will not have any
On Sun, Jul 25, 2010 at 7:41 AM, Raghu Maddali <raghu1216@yahoo.co.in>wrote:
[#366478] nmap-1.1.0 — "ara.t.howard" <ara.t.howard@...>
NAME
[#366487] General delimiters — "Иван Сташко" <johns@...>
I would like to create a new general delimiter.
[#366488] * operator, Float — "Иван Сташко" <johns@...>
Where is the * operator defined for Float?
[#366493] Module inclusion and class macro problem — Rolf Pedersen <rolfhsp@...>
Hi
[#366494] soap with ruby 1.9 ? — Dani Dani <laguna53@...>
Hi all, does anyone know how can I implement soap to access web services
[#366519] ruby calc.rb or just calc.rb — Kaye Ng <sbstn26@...>
Beginner here (in ANY programming language), so pls bear with me.
You need to set your path top the Ruby bin directory. The error: 'ruby' is
[#366521] stop program with entering a key... — hazal Ates <niyaziates77@...>
i m a new in Ruby . sorry may be its a silly question.
The following code doesn't do exactly what you need, but it should be
Michael Jackson wrote:
[#366525] RubyGems.org Still Down? — Intransition <transfire@...>
http://rubygems.org/
[#366541] Directory structure best practice? — MrZombie <mrzombie@...>
Hi all!
[#366543] Issue with mongrel and apache. — Allan Davis <javaalley@...>
I just upgraded rails to 2.3.8 on my test server and now the apache is
[#366544] Help: How to pass a struct as a pointer to Win32API? — Jing Li <thyrlian@...>
Hi all,
[#366546] interactive ruby development — Seshu Yamajala <syamajala@...>
As someone who has used lisp, emacs, and slime in the past, I get
[#366558] Beginner help needed: use a class def to create new instance — "Steve P." <stevepauly@...>
I am attempting to put as much code inside classes as possible, to
On Tue, Jul 27, 2010 at 6:36 AM, Steve P. <stevepauly@comcast.net> wrote:
[#366590] Where can I find the 'shebang' line? — Ast Jay <azzzz@...>
I seem to be having trouble with RVM (after an update to Rails 3 RC),
On Tue, Jul 27, 2010 at 12:10 PM, Ast Jay <azzzz@gmx.net> wrote:
[#366611] Which Ruby is in use? — Hassan Schroeder <hassan.schroeder@...>
Is there a way to tell from within a program which executable is being
On Tue, Jul 27, 2010 at 2:20 PM, Joseph E. Savard
Hassan Schroeder wrote:
On Tue, Jul 27, 2010 at 3:10 PM, Joel VanderWerf
Hassan Schroeder wrote:
On Tue, Jul 27, 2010 at 3:52 PM, Joel VanderWerf
Hassan Schroeder wrote:
On Tue, Jul 27, 2010 at 4:45 PM, Joel VanderWerf
hope I did not misunderstand the question, but would this work??
On Tue, Jul 27, 2010 at 7:03 PM, Fabian Marin <fmg134s@yahoo.com> wrote:
On 07/28/2010 11:20 AM, Hassan Schroeder wrote:
Edward Middleton wrote:
On 7/27/10, Fabian Marin <fmg134s@yahoo.com> wrote:
On Tue, Jul 27, 2010 at 11:41 PM, Caleb Clausen <vikkous@gmail.com> wrote:
[#366618] Chat client — Daniel Flores <soloparamsn2@...>
hello i was learning about ruby and on the book i am reading it shows
[#366629] tool to compare DB schema against DDL file — Fabian Marin <fmg134s@...>
First of all any feedback from you guys will be of tremendous help.
On 28.07.2010 03:57, Fabian Marin wrote:
Robert Klemme wrote:
[#366630] multidimensional array insert syntax — Dave Castellano <dcastellano1@...>
Hi,
On Wed, Jul 28, 2010 at 4:02 AM, Dave Castellano
Jesús Gabriel y Galán wrote:
On 28.07.2010 12:56, Dave Castellano wrote:
[#366658] Problem in loop do — Amir Ebrahimifard <amiref@...>
Hi
[#366673] Object#tap (was Nice algorithm for 'spreading' indexes across an array?) — Harry Kakueki <list.push@...>
On Wed, Sep 2, 2009 at 1:41 AM, Max Williams<toastkid.williams@gmail.com> wrote:
[#366692] rubyw, RuntimeError, capturing the stack, FXRuby — Ralph Shnelvar <ralphs@...32.com>
Let's say I'm running rubyw and a RunTimeError is raised ...
[#366699] how to determine array element number in a each loop — Kaya Aykut <kaya.aykut@...>
Hello all, newbie here.
[#366707] 64 bit ruby installation on 64 bit windows — Ichigo Poi <dxtrdrosario@...>
hi, could anyone help me answer the following questions.
[#366709] hitimes 1.1.0 Released — Jeremy Hinegardner <jeremy@...>
hitimes version 1.1.0 has been released.
[#366718] Problem with concurrency — Tasos Laskos <zapotek@...>
Hi guys,
On 07/29/2010 07:55 AM, Tasos Laskos wrote:
[#366727] my script just read one line? — Junhui Liao <junhui.liao@...>
Dear all,
On Thu, Jul 29, 2010 at 1:43 PM, Junhui Liao <junhui.liao@uclouvain.be> wro=
Dear Jes炭s Gabriel y Gal叩n and all,
On Fri, Jul 30, 2010 at 1:58 AM, Junhui Liao <junhui.liao@uclouvain.be> wro=
On Fri, Jul 30, 2010 at 2:18 PM, Junhui Liao <junhui.liao@uclouvain.be> wro=
Dear Jes炭s Gabriel y Gal叩n,
On Fri, Jul 30, 2010 at 4:00 PM, Junhui Liao <junhui.liao@uclouvain.be> wro=
Hi, Jesus.
On Sun, Aug 1, 2010 at 11:10 PM, Junhui Liao <junhui.liao@uclouvain.be> wro=
Hi, Jesus,
On Tue, Aug 3, 2010 at 12:15 AM, Junhui Liao <junhui.liao@uclouvain.be> wro=
Hi, Jesus,
[#366730] ruport, reading a csv whose column name have white spaces — Fourchette Fourchette <alexisdal@...>
hi there,
[#366751] how to read password from keyboard — Bruno Sousa <brgsousa@...>
Hi everyone!
[#366752] Problem with a lambda not executing immediately — Fernando Perez <pedrolito@...>
Hi,
On Thu, Jul 29, 2010 at 10:38 PM, Fernando Perez <pedrolito@lavache.com> wr=
> Given that the key in the hash is
[#366755] .any?{} Behavior — John Sikora <john.sikora@...>
I find the following behavior interesting (so interesting that I
On Thu, Jul 29, 2010 at 5:27 PM, John Sikora <john.sikora@xtera.com> wrote:
On Fri, Jul 30, 2010 at 10:49 AM, Rick DeNatale <rick.denatale@gmail.com>wrote:
Josh Cheek wrote:
On Sun, Aug 1, 2010 at 12:28 PM, Maurizio De Santis
On Sun, Aug 1, 2010 at 11:46 AM, Rick DeNatale <rick.denatale@gmail.com>wrote:
On Sun, Aug 1, 2010 at 12:24 PM, Hal Fulton <rubyhacker@gmail.com> wrote:
Hi --
what about "all_and_not_empty" ?
[#366769] binary encode 7 ([7].pack("C")) as "\007" instead of "\a" — Woody Peterson <woody.peterson@...>
I have a problem that's on the borders of ruby and erlang, but I'm
[#366785] Compiling Ruby through JRuby? — MrZombie <mrzombie@...>
Hi! I'm currently building a program which will be mostly standalone,
[#366790] how to find difference between two strings — Priyank Shah <shahpriyank01@...>
Hi,
[#366793] Will paginate question — "Bla ..." <bianca.stephani@...>
I have the following code:
[#366798] SVG generation gem? — Rick DeNatale <rick.denatale@...>
I've recently started playing with an Epilog laser cutter, and I find
[#366822] multiple connections with DBI and Mysql — Dave Lilley <dglnz2@...>
Can anyone here advise me the best way to have two classes access mysql
[#366829] Ruby Webbrowser — Kai Dölger <kgd92@...>
Hey Guys,
On Sat, Jul 31, 2010 at 8:13 AM, Kai D=F6lger <kgd92@msn.com> wrote:
[#366837] Mocking a method with a block — Fernando Guillen <fguillen.mail@...>
Hi people,
On Sat, Jul 31, 2010 at 5:38 PM, Fernando Guillen
Fernando Guillen wrote:
Brian Candler wrote:
Method error
I use sipsorcery for my SIP-calls, which uses a ruby dialplan.
The dialplan i got from
http://forum.sipsorcery.com/viewtopic.php?f=15&t=826 raises an exception
when I make an outgoing call.
Unfortunately, my ruby knowledge is very limited. Can someone tell
what's wrong?
Exception:
DialPlan=> ** Error: undefined method `fixupNumber' for
#<TNumber:0x0000370>
Thanks in advance.
ruby code:
#Ruby
# Original by MikeTelis
(http://www.mysipswitch.com/forum/viewtopic.php?t=706)
#
# Adapted by Mike Green as following:
#
# ******************************* Configuration
*******************************
# This section is where you can change the behavior of all the
functions.
# Change these according to your needs.
#
*****************************************************************************
# Specifies the host name required to place a local (MSS to MSS)
call.
#
# LocalDomain = "sip.mysipswitch.com"
LocalDomain = "sip.mysipswitch.com"
# Specifies the canonical / IP host name(s) of the local MSS server.
Used to
# determine if a call is MSS to MSS, or MSS to PSTN/URI
#
# Domains = [LocalDomain, "213.200.94.182"]
Domains = [LocalDomain, "213.200.94.182"]
# It is possible to define your own "local" area code for making MSS
to MSS
# calls. Dialing any number preceeded by the value define will route
a call
# internally, instead of making a call to a PSTN. If you do not wish
to use
# this feature, leave it blank.
#
# LocalAreaCode = ""
LocalAreaCode = "026"
# Specifify if a 9 needs to be dialed to make a call outside of the
local
# MSS work. If enabled, a call to 5551212 would be routed to
5551212@(LocalDomain)
# and a call to 95551212 would be routed to
5551212@(a_sip_provider).
#
# This function cannot be combined with the LocalAreaCode option.
#
# DialNineOut = true
DialNineOut = false
# Enabling this option forces the User ID to be used the caller ID
(if supported
# by the provider).
#
# UserIDAsOutgoingCallerID = false
UserIDAsOutgoingCallerID = false
# Your local country code. This is used to replace the leading 0.
For example,
# a number dialied as 0203112233 in the Netherlands would be
converted to
# 31203112233 if MyCountryCode = "31".
#
# For North America (Country Code 1), the number will be prepended
to the
# dialed number, unless it is already present. Ie., 2125551212 will
become
# 12125551212.
#
# Use MyCountryCode = "" if no conversion is desired.
#
# MyCountryCode = ""
MyCountryCode = "31"
# The Time Zone offset based from GMT. Ie., London is 0, Paris is
+1, New York
# is -5 and Kolkata is +5:30.
#
# !NOTE: It does not account for Daylight Savings, as it depends per
country
# (and the server on which MySipSwitch is deployed)
#
# If unsure, visit
http://www.timeanddate.com/worldclock/difference.html
#
# MyTimeZone = "-5"
# MyTimeZone = "+5:30"
MyTimeZone = "+1"
# Specify whether ENUM lookup should be used as the preferred method
of calling.
#
# You can override this function by dialing the number with *9
#
# UseENUM = false
UseENUM = true
# Default Callback Number. This number will be used in case the
bridge/callback
# option is used, but no 2nd number was dialed.
#
# If the entry is empty, the default will be "yourself", as in
# <sip:yourusername@mysipswitch.com>
#
# DefaultCallbackNumber = ""
DefaultCallbackNumber = ""
# Specify how long one particular number should ring until the next
number in
# the list is dialed.
#
# DefaultDelay = 10
DefaultDelay = 10
# Speed Dial numbers.
#
# Syntax: "(number)" => "(actual number or URI)"
#
# NOTE: It is valid to use special functions in Speed Dial!
#
# Speeddial = { "0" => "303@sip.blueface.ie", "1" =>
"**500@voxalot.com" }
Speeddial = {
"9901" => "613@fwd.pulver.com", # Echo test USA
"9949" => "enum-echo-test@sip.nemox.net", # Echo test Germany
"9944" => "sip:904@mouselike.org", # Call quality test UK
"303" => "303@sip.blueface.ie", # Calls speaking time @
blueface
"612" => "612@fwd.pulver.com" # Calls speaking time @ pulver
}
# Providers table.
#
# Syntax: "Key" => "[Prefix]@Provider"
#
# Where:
# Key A single digit, 0 being the default.
# Prefix Optional prefix that needs to be added to the
dialed number.
# Provider Provider by name, as listed in MySipSwitch
configuration.
#
# You can override the provider by dialing a number with the prefix
*1 and then
# the key. For example:
#
# *1412125553456 dials 12125553456 using the provider at key 4
#
# VSPtable = { "0" => "@ provider1", "1" => "@ provider2" }
VSPtable = {
"0" => "@12voip", # default provider (prefix numbers with 00)
"1" => "@budgetphone" # budgetphone
}
# Provider rules.
#
# Syntax: "Rule" => "Provider"
#
# Where:
# Rule A regular expression (Regexp) to match against a
number
# Provider Provider by key, as listed in VSPtable above
#
# NOTE: Use a double backslash for a single one!
#
# VSPRules { "^\\*1" => "0", "^\\*2" => "1" }
VSPRules = {
"^#{MyCountryCode}|^0" => "0" # A national (local)
number
# "^[1]800|866|877|888\\d{7,7}$" => "4", # North America Toll
Free numbers
# "^1[2-9]\\d{9,9}$" => "2" # North America
}
# Answer rules.
#
# Syntax: "Rule" => "Options"
#
# Where (CaSe Senitive!):
# Rule * Times between which calls will be answered, OR
# * "unavailable" : the rule when the user is
unavailable, OR
# * "default" : the default rule, for which none of
the other
# rules match.
# Options * "decline" : to decline the call with this
rule, OR
# * One or more numbers to call.
#
# Multiple numbers seperated by a '&' sign will be called
simultaneously. All #
# phones will ring, until one of them is answered.
#
# Example: "12:00-14:00" =>
"homephone@asip.com&mobilephone@asip.com"
#
# Multiple numbers seperated by a '#' will be called in the order
# listed. The numbers can be limited to a maximum "wait for answer"
time by
# adding a '!' sign followed by the amount of seconds (15 seconds is
the
# internal limit).
#
# Example: "12:00-14:00" =>
"homephone@asip.com!10#mobilephone@asip.com!10"
# This will call "homephone", ringing up to 10 seconds and if not
answered will
# proceed to call "mobilephone", also ringing for up to 10 seconds
AnswerRules = {
# "17:30-21:30" => "mobilephone@asip.com&homephone@asip.com",
# "21:30-23:00" => "homephone@asip.com",
# "23:00-6:00" => "decline",
# "6:00-17:30" =>
"officephone@asip.com!10#homephone@asip.com!5",
# "$unavailable" => "mobilephone@asip.com",
"$default" => "#{sys.Username}@local"
# "18885551212" => "*3callback1#callback2"
}
# Excluded Prefixes. Provides a safeguard against accidentally
calling premium
# numbers.
#
# Syntax: "(number)"
#
# Where:
# (number) Any number(s) at the start of a dialed number
#
# The numbers need to start with the country code. You can also use
this to
# block entire numbers from being dialed. To override this function,
dial the
# number with *2.
#
# *219005553456 dials 19005553456, bypassing the safeguard
#
# ExcludedPrefixes = [ "118118", "411", "1900" ]
ExcludedPrefixes = [
"1900", "1976", # USA Premium
"449", "4455", "44870", "44871", # UK Premium
"44844", "44845", # UK Local Premium
"4470", # UK Personal Premium
"438", "439", # Austria Premium
"327", "3290", # Belgium Premium
"451", "45501", "45502", "45503", # Denmark Premium (...)
"45701", "45702", "4580", "4590", # Denmark Premium
"337", "339", # France Premium
"491", "49900", # Germany Premium
"391", "392", "394", "395", # Italy Premium (...)
"396", "397", "398", "399", # Italy Premium
"3114", "3163", "3168", "3169", # Netherlands Premium (...)
"318", "319", # Netherlands Premium
"4839", "4820", "4870", "4880", # Poland Premium
"46900", "46939", "46944", # Sweden Premium
"41900", "41901", "41906" # Switzerland Premium
]
# ********************************** DEFINES
**********************************
# For basic functionality of this plan, it should not be neccesary
to
# edit the code below.
#
*****************************************************************************
# DO NOT CHANGE THE TWO LINES BELOW!
Sys = sys
Req = req
###
def fixupNumber(aNumber)
number = String.new(aNumber =~ /^(.+)@(.+)$/ ? $1.to_s : aNumber)
host = $2.to_s.downcase
port = host.sub!(/\:(\d+)/, "") ? $1 : ""
if (host == "local")
# It's a MSS user -> MSS user call
number << "@" << LocalDomain
elsif (host == "") or (Domains.find{|x| x.downcase == host})
# It's a MSS user -> PSTN call, unless LocalAreaCode is
matched.
# A LocalAreaCode is not valid if a 9 needs to be dialed for
outgoing calls.
if (!LocalAreaCode.empty?) and (!DialNineOut)
# We have a LocalAreaCode, but we'll also check in case it
was
# dialed with the country code (if specified)
LACC = LocalAreaCode.gsub(/^0/, MyCountryCode)
if number.sub!(/^#{LocalAreaCode}/,"") or
(number.sub!(/^#{LACC}/, "") unless MyCountryCode.empty?)
number << "@" << LocalDomain
end
elsif DialNineOut
number << "@" << LocalDomain unless number.sub!(/^9/, "")
end
else
# It's a MSS -> URI call
number << "@" << host
end
number << ":" << port unless port.empty?
return number
end
###
# TNumber class
#
# Container for each particular number, with a seperate handler
#
class TNumber
attr_reader :number, :provider, :override, :enum, :useenum,
:timeout
attr_writer :number, :provider, :override, :enum, :useenum,
:timeout
def initialize(aNumber)
@number = fixupNumber(aNumber)
# @number = Speeddial[@number] if (Speeddial[@number])
@provider = ""
@override = false # Used for overriding excluded prefixes
@useenum = UseENUM
@enum = "" # Initialize ENUM var
@timeout = extractDialTimeout(@number)
end
# Prepares the number for dialing.
#
def prepare
return 0,"" if is_URI?
# sub! below removes prefixes:
# '+' - international format
# 00 - European style international prefix (00)
# 011 - US style international prefix (011)
# 810 - Russian style international prefix (810)
unless @number.sub!(/^(\+|00|011|810)/,"")
# Convert a national number to an international number
case MyCountryCode
# North America
when "1"
# Prepend a North American number with the country
code,
# unless it already starts with the country code
@number = MyCountryCode + @number if @number =~
/^[^1]/
# Russia (From MikeTelis' original code)
when "7"
case @number
when /^82\d{7,7}$/
@number = "7496" + @number[2..-1]
when /^8/
@number[0] = "7"
when /^[1-9]\d{6,6}$/
@number = "7495" + @number
end
else
# Apply default rule (replace 0 with country code),
unless
# MyCountryCode is not specified.
@number.sub!(/^0/, MyCountryCode) unless
MyCountryCode.empty?
end
end
# Check if we can override the prefix, and if not, see if it's
in
# the list of exluded prefixes.
if !@override and hasExludedPrefix = ExcludedPrefixes.find
{|prefix| @number =~ /^#{prefix}/ }
return 403,"Numbers starting with #{hasExludedPrefix} are
not permitted"
end
# If the provider was not specified by the user, we will
decide it here
if @provider.empty?
getEnum if @useenum
selectProvider
end
return 0,""
end
# Selects the provider based on the number.
#
def selectProvider
# Fix North American numbers that are longer than usual
@number = $1 if @number =~ /(^1([2-9]\d\d)\d{7,7})/
@provider = "0" # Set the default provider first
VSPRules.each { |aRule|
if @number =~ /#{aRule[0]}/
@provider = aRule[1]
break
end
}
end
# Extracts the timeout specified with the number
def extractDialTimeout(aNumber)
return aNumber.sub!(/\!(\d{1,2})/, '') ? $1.to_i : 0
end
# Are we using the ENUM to call?
#
def use_ENUM?
return !@enum.to_s.empty?
end
# Is it a full URI instead of a number?
#
def is_URI?
return @number =~ /@/
end
# Expands the number based on the providers' template, to be used
# in Sys.Dial
#
def expandNumber
if tpl = VSPtable[@provider]
return tpl.sub(/\s*@\s*/) {|x| @number+"@"}
else
return @number
end
end
# Sets the enum variable, if an ENUM is available
#
def getEnum
Sys.Log("Attempting to retrieve ENUM for #{@number}")
@enum = "" unless @enum =
Sys.ENUMLookup("+#{@number}.e164.org").to_s
Sys.Log("Result ENUM lookup: '#{@enum}'")
end
private :getEnum
end
# TDialList class
#
# Controls the numbers and call methods
#
class TDialList
attr_reader :bridgenumbers
MaxItems = 10
def initialize
@numbers = Array.new
@bridgenumbers = false
end
# Add a number to the list
#
def append(aNumber)
return 500,"Exceeded limit or class error" if (@numbers.length
== MaxItems) or (aNumber.class.name != "TNumber")
if !aNumber.is_URI?
Code,Reason = processSpecialFunctions(aNumber)
return Code,Reason if Code > 0
end
@numbers.push(aNumber)
return aNumber.prepare
end
# How many numbers do we have?
#
def length
@numbers.length
end
def deleteFirst
@numbers.shift
end
def deleteLast
@numbers.pop
end
# Access to the numbers, by index (key) or phone number
#
def [](key)
return @numbers[key] if key.kind_of?(Integer)
return @numbers.find { |aNumber| key == aNumber.number }
end
# Handles any special function present in the number
#
# Special Functions:
#
# *1(key) Override the provider with the one specified in
(key)
# *2 Bypass premium number safeguard
# *3 Bridge (callback) the numbers
# *9 Override ENUM setting (enable if disabled, and
vice versa)
# *0 Trace the phone call
# ** Dial a *
#
def processSpecialFunctions(aNumber)
while aNumber.number.sub!(/^\*([^\*])/, "")
case $1
# Special function 1 - Override provider
when "1"
aNumber.number.sub!(/^(.)/, "")
aNumber.provider = $1;
return 400,"Invalid provider selected #{$1}" if
VSPtable[aNumber.provider].to_s.empty?
Sys.Log("! Overriding service provider for
#{aNumber.number} to #{aNumber.provider}, template
#{VSPtable[aNumber.provider]}")
# Special function 2 - Bypass safeguard
when "2"
Sys.Log("! Bypassing premium number safeguard for
#{aNumber.number}")
aNumber.override = true
# Special function 3 - Bridge the numbers in the list
(will take only first two)
when "3"
Sys.Log("! Request to bridge #{aNumber.number}")
@bridgenumbers = true
# Special function 0 - Trace this particular call
when "0"
Sys.Log("! Requested a trace for this call.")
Sys.Trace = true
# Special function 9 - Override the use of ENUM
when "9"
Sys.Log("! Override use of ENUM")
aNumber.useenum = !aNumber.useenum
# Unknown function
else
Sys.Log("! Unknown function in dial sequence found:
#{$1} - Ignoring")
end
end
# A double ** gets treated as a single * to dial
aNumber.number.sub!(/^\*/,"")
return 0,""
end
# Make the call
#
def dial(*args)
if Sys.Out and UserIDAsOutgoingCallerID
Req.Header.From.FromName =
Req.Header.From.FromURI.User.to_s
end
if @bridgenumbers
# If no default callback number is set, use local user
DefaultCallbackNumber = "#{Sys.Username}@local" if
DefaultCallbackNumber.empty?
number1 = @numbers[0].use_ENUM? ? @numbers[0].enum :
@numbers[0].expandNumber
number2 = (length < 2) ? DefaultCallbackNumber :
@numbers[1].use_ENUM? ? @numbers[1].enum : @numbers[1].expandNumber
Sys.Log("* Initiating bridge between #{number2} and
#{number1}")
Sys.Callback(number2, number1, 3) # 3 seconds before
dialing
else
# If there's more than one number in the list, try each one
until
# one is picked up. (No ring timeout for single number)
ringtimeout = 0
@numbers.each { |n|
numbertd = n.use_ENUM? ? n.enum : n.expandNumber
# If there's more than 1 number to call, set the
timeout if present.
ringtimeout = n.timeout == 0 ? DefaultDelay :
n.timeout if (length > 1)
if ringtimeout == 0
Sys.Log("* Dialing #{numbertd}")
Sys.Dial(numbertd)
else
Sys.Log("* Dialing #{numbertd} with timeout
#{ringtimeout}")
Sys.Dial(numbertd, ringtimeout)
end
}
end
return status
end
# Grab the status from the LastDialied list (Another great piece
by MikeTelis)
#
def status(li=0)
if (ptr = Sys.LastDialled[li]).nil?
return 487,"Cancelled by MSS"
else
ptr = ptr.TransactionFinalResponse # SIPTransaction &
SIPResponse
return ptr.StatusCode,ptr.ReasonPhrase
end
return 0,""
end
end
# Inbound Call Manager. Uses a rule-based table to determine where
# an incomming call should be routed to, based on time of day and
# availability.
#
class TInboundMgr
attr_reader :time
@@localuser = "#{Sys.Username}@local"
def initialize
@time = Time.now.gmtime # In case this SIP Switch is
deployed outside Dublin
# Some timezones have half hour and 45 minute differences.
Account for this.
# It does NOT account for daylight savings!
mtz = MyTimeZone.split(":")
mtz[0] = '0' if mtz[0].to_s.empty?
@time += mtz[0].to_i * 3600
@time += mtz[0][0].chr == "-" ? ("-#{mtz[1]}".to_i * 60) :
(mtz[1].to_i * 60) unless mtz[1].to_s.empty?
Sys.Log("Using #{@time} to determine Answer Rule")
callerid_name = Req.Header.From.FromName.to_s
# Some SIPs simply leave the name blank, which some softphones
don't
# appreciate
callerid_name = Req.Header.from.FromURI.User.to_s if
callerid_name =~ /^$|\D/
# Replace any characters other than A..Z or numbers. This
could happen
# with SIPBroker for instance ("Calgary,AB
<sip:xxx@sipbroker.com>)
callerid_name.gsub!(/[^a-zA-Z0-9]/, " ");
# Add a 1 if it's a US 9-digit number.
callerid_name = ("1" + callerid_name) if callerid_name =~
/^[2-9]\d{9,9}$/
# Be careful with changing headers. You could end up spending
a lot of
# time debugging, checking why a call isn't going through!
(Been there!)
Req.Header.from.FromURI.User = callerid_name
Req.Header.From.FromName = callerid_name
@NumbersToCall = TDialList.new
end
def Answer
# Grab the rules
tr = getTimeRule
ur = getUnavailableRule
# Insert unavailable rule, if needed
unless ur.empty?
tr.gsub!(/#{@@localuser}/, ur) if !Sys.IsAvailable
end
Sys.Log("Answer Rule used: #{tr}")
# Start dialing each number in the rule, unless rule is set to
decline
unless tr == "decline"
tr.split("#").each { |number|
Code,Reason = @NumbersToCall.append(TNumber.new(number))
# If there was an error adding the number, don't let it
break
# the answer rules, just remove it from the numbers to
call.
@NumbersToCall.deleteLast if Code > 0
}
@NumbersToCall.dial
end
# If we end up here, that means the numbers dialed weren't
answered or
# the rule is set to decline the call.
Sys.Log("Exhausted answer options (or decline rule).")
return 408, "#{@@localuser} is not available"
end
# Returns the time rule, based on the current sys time. Will
return
# a default rule if no time rule exists.
#
def getTimeRule
result = ''
AnswerRules.each { |rule|
# If the rule contains a from-to time format
if
rule[0].match(/^(\d{1,2}):(\d{2,2})-(\d{1,2}):(\d{2,2})$/)
# From what time do we start to check?
t1 = Time.gm(@time.year, @time.month, @time.day,
$1.to_i, $2.to_i)
# And until what time? (We decrease the time by a
second)
t2 = Time.gm(@time.year, @time.month, @time.day,
$3.to_i, $4.to_i)
t2 -= 1
# If the start time is beyonthe end time, decrease start
time
# by 24 hours
t1 -= (3600 * 24) if t1 > t2
result = rule[1] if @time.between?(t1,t2)
else
unless rule[0] =~ /^\$/
result = rule[1] if Req.Header.From.FromName.to_s =~
/#{rule[0]}/
end
end
}
return result if !result.to_s.empty?
# If we end up here, it means we couldn't find a matching time
rule.
# So we look for a default rule. If none, we make a default
rule.
if AnswerRules["$default"]
return AnswerRules["$default"]
else
return @@localuser
end
end
# Returns the rule for handeling unavailable user. Will return
# empty if no rule available.
#
def getUnavailableRule
return AnswerRules["$unavailable"].to_s
end
end
# A helper for figuring out if the number is:
# 1) a local call (MSS user -> MSS user)
# 2) an URI call (MSS user -> SIP Provider user)
# 3) a dialed phone call (MSS user -> PSTN)
#
def fixupNumber(aNumber)
number = String.new(aNumber =~ /^(.+)@(.+)$/ ? $1.to_s : aNumber)
host = $2.to_s.downcase
port = host.sub!(/\:(\d+)/, "") ? $1 : ""
if (host == "local")
# It's a MSS user -> MSS user call
number << "@" << LocalDomain
elsif (host == "") or (Domains.find{|x| x.downcase == host})
# It's a MSS user -> PSTN call, unless LocalAreaCode is
matched.
# A LocalAreaCode is not valid if a 9 needs to be dialed for
outgoing calls.
if (!LocalAreaCode.empty?) and (!DialNineOut)
# We have a LocalAreaCode, but we'll also check in case it
was
# dialed with the country code (if specified)
LACC = LocalAreaCode.gsub(/^0/, MyCountryCode)
if number.sub!(/^#{LocalAreaCode}/,"") or
(number.sub!(/^#{LACC}/, "") unless MyCountryCode.empty?)
number << "@" << LocalDomain
end
elsif DialNineOut
number << "@" << LocalDomain unless number.sub!(/^9/, "")
end
else
# It's a MSS -> URI call
number << "@" << host
end
number << ":" << port unless port.empty?
return number
end
# *********************************** MAIN
************************************
# This is where all the action happens, depending on incomming or
outgoing calls
#
*****************************************************************************
begin
timeit = Time.now
Sys.Log("** Call from #{Req.Header.From.ToString} to
#{Req.URI.ToString} **")
Code = 500
Reason = 'Internal error'
if Sys.In # Incoming call...
InboundManager = TInboundMgr.new
Code,Reason = InboundManager.Answer
else # Outbound call ...
dest = String.new(Req.URI.ToString.to_s)
dest.sub!(/^sip:/, "") # strip "sip:"
dest.gsub!(/%../) {|x| x[1,2].to_i(16).chr} # Convert %hh
into ASCII
# Is it a Speeddial? (Nested speeddial no longer supported,
"adest" is
# simply a temporart placeholder.
adest = fixupNumber(dest)
dest = Speeddial[adest] if (Speeddial[adest])
# Create a new Dial List
NumbersToCall = TDialList.new
# Grab the phone number(s), seperated by a '#'
dest.split("#").each { |number|
# Add the number.
Code,Reason = NumbersToCall.append(TNumber.new(number))
# Did anything bad happen while adding this number?
break if Code > 0
}
# Will stop script here if Code >= 200, ie error adding number
Sys.Respond(Code, Reason) if Code > 0
Code,Reason = NumbersToCall.dial
end
Sys.Respond(Code, Reason)
rescue
# Gives a lot more details at what went wrong. Don't worry about
the Thread Exit.
Sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being
aborted./
ensure
Sys.Log("Time to complete Dial Plan: " + (Time.Now -
timeit).to_s)
end
--
Posted via http://www.ruby-forum.com/.