[#408616] How to get the User_logged in windows with Sinatra — Mario Ruiz <lists@...>
I need to know the user that is accessing the intranet i created with
[#408620] including FileUtils::Verbose crashes Marshal.dump — Bryan Lockwood <lockwood.bryan@...>
This is a bug I ran into today. I'm not sure who's responsible for =
[#408622] Error with JSON#parse — Love U Ruby <lists@...>
require 'json'
The same with `YAML#load`
[#408624] Why the use of a pound (#) sign with Enumerable — Ruby Student <ruby.student@...>
Team,
[#408634] How do I make lots of classes aware of each other? — "Andrew S." <lists@...>
I'm apparently missing something fundamental in my knowledge of classes
You can use send which as you would expect sends messages to an object. You
Thanks.
[#408654] Backtick probleme — xcoder Blue_fox <lists@...>
Hey guys i got a probleme with this code :
[#408662] How can I add minutes,seconds and hours to a DateTime object? — Love U Ruby <lists@...>
require 'date'
[#408668] Implementing sort/sort! — Kyle Hunter <lists@...>
Hello,
On Wed, Jul 3, 2013 at 4:39 AM, Kyle Hunter <lists@ruby-forum.com> wrote:
[#408680] Difference between Kernel#__callee__ and Kernel#__method__ — Love U Ruby <lists@...>
Is there any Difference between Kernel#__callee__
[#408684] rake drake or ? — Marc Weber <marco-oweber@...>
Is there yet another alternative to drake vs rake?
[#408701] Loading csv giving error — Nithi anand <lists@...>
hi guys I am trying to compare some data so I create one file name
[#408712] Ruby web service with REST support — "Shubhada S." <lists@...>
Hi All,
I would suggest you install the Sinatra gem, and read the
On Fri, Jul 5, 2013 at 12:03 PM, Matthew Kerwin <matthew@kerwin.net.au>wrote:
Robert Klemme wrote in post #1114499:
On Mon, Jul 8, 2013 at 7:42 AM, Shubhada S. <lists@ruby-forum.com> wrote:
I am still confused when to use phusion passenger and when to use rails?
[#408713] Ruby link grabber — xcoder Blue_fox <lists@...>
Hey guys i wanted to write a ruby code to grab all links from html code
[#408724] How do I rescue a program exception in an at_exit block? — Josh Cheek <josh.cheek@...>
I was thinking about how bad I am at reading error messages, and realized
On Fri, Jul 5, 2013 at 4:08 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
[#408734] what is Vector#map2 ? — Love U Ruby <lists@...>
Hi,
[#408745] How can I make ruby read a string of characters per three characters? — Sam Thorpe <lists@...>
I want to input a string of characters, and have it be read by every
[#408757] Parslet: subtrees merged without warning? — Axel Friedrich <lists@...>
Hi,
> Or, in which cases results are lost/merged silently?
Hallo Kaspar,
> Could I easily add some extension code to get a message in this case,
> Probably
> I think, I haven't understood the "philosophy" of Parslet yet. There are
[#408778] Price lookup from sketchup to csv — Nithi anand <lists@...>
I need to perform a lookup on a CSV file.
[#408787] execute_script - selenium-webdriver — Love U Ruby <lists@...>
HTML:
[#408788] A very half-baked idea: setting local variables — Hal Fulton <rubyhacker@...>
I'm sure this nonexistent feature is not in great demand, but there have
[#408795] Well-Grounded Rubyist -- Person class implementation in chapter 4 question — Arslan Farooq <lists@...>
Hi,
[#408801] Help me to understand a Ruby file — Salvo Foru <lists@...>
Hello everyone, I'm a new to the site and I'm just starting to learn
[#408808] how to compile .so on windows — Dimmak SDI <lists@...>
Plese help me!
[#408812] create variables depending on counter — stefan heinrich <lists@...>
Hi community,
Hi Robert and Marcus,
Ok i got it. Thank you so much.
[#408819] search a string with ruby then read what comes after the string in the same line — dJD col <lists@...>
I am trying to look for a a given string in a text and once i find the
[#408842] Why can't I just subtract in a loop without restating the variable? — Wayne Brisette <wbrisett@...>
I have some code that uses a counter. In certain circumstances, I have to s=
[#408854] execute commands within SMTP email code: send content in variables and not actual variables — dJD col <lists@...>
I am trying to send an email using the code below. I am able to send the
I was able to print the values of the variables t and s
[#408894] phusion passenger + uninitialised constant+ NameError — "Shubhada S." <lists@...>
Hi,
[#408906] how to upgrade to the latest version of ruby ? — Love U Ruby <lists@...>
I am using RVM with Ubuntu13.04. Installed version of Ruby is :
[#408911] Module Confusion — "Michael W." <lists@...>
The below code works. Question though. How does add_to_stack acess the
[#408925] closing a socket while another thread is in an IO.select() call on it — Graham Menhennitt <graham@...>
Hello Rubyists,
[#408927] Ticket for eurucamp 2013 — Jens Hausherr <jabbrwcky@...>
Hi Rubyists,
[#408937] Get part of matrix — "Diego N." <lists@...>
Hi!
[#408944] Kernel.caller Performance Across Different Ruby Versions — Peter Giacomo Lombardo <lists@...>
I wrote a quick Ruby script to benchmark Kernel.caller using ruby-prof.
[#408955] Iteration anomalu — "Andrew D." <lists@...>
Surely this is a FAQ but I can't figure out how I would search for an
[#408963] Allowing a character through Addressable::URI unescaped — Joel Pearson <lists@...>
I have some code which used to work a few months ago but appears to have
[#408970] Install RVM on Solaris — "Chamila W." <lists@...>
I tried installing RVM on Solaris using command
[#408976] TryRuby Popup Problems — "Jayant S." <lists@...>
Hello there, my name is Jay. I wanted to introduce myself because I
[#408990] Hash#update - need tweaks — Love U Ruby <lists@...>
I am in a situation,where I have to the below kind of operations.
[#408994] Ruby Debugger — Alphonse 23 <lists@...>
Could anybody recommend me a good Ruby Debugger. Preferably one that
[#408995] ActiveSupport undercore behaviour — Serguei Cambour <lists@...>
I tried to use ActiveSupport 'underscore' method to convert some
tamouse m. wrote in post #1116149:
I am on the phone, but my guess is that the quotes and backslashes are
I changed as follows and it works for the first nest level for the
On Sun, Jul 21, 2013 at 7:03 AM, Serguei Cambour <lists@ruby-forum.com>wrote:
[#409008] Unsubscribe? — James Murphy <jamurphy84@...>
Hi all,
[#409031] tap { break } idiom deserves its own Kernel method? — Andy Lowry <lists@...>
I use this idiom from time to time:
On Mon, Jul 22, 2013 at 7:37 PM, Andy Lowry <lists@ruby-forum.com> wrote:
On Mon, Jul 22, 2013 at 10:37 AM, Andy Lowry <lists@ruby-forum.com> wrote:
I just used the pattern again, and this time it's a much simpler example
[#409046] Question on while loop to script — "Talal B." <lists@...>
Hi guys,
[#409047] using qsub from Ruby script produces "command not found" — Thomas Luedeke <lists@...>
I am running a script that runs multiple cases on an engineering code.
[#409052] How can we create instance method and class methods at runtime in ruby? — Love U Ruby <lists@...>
How can we create instance method and class methods at runtime in ruby?
Sorry for creating the confusions:-
[#409064] how to create structure like bellow — Expert Alart <lists@...>
Hi...
[#409072] Link To Masses Of External Data In Openoffice? — "Austin J." <lists@...>
This is what I want to do.
tamouse m. wrote in post #1116598:
tamouse m. wrote in post #1116750:
tamouse m. wrote in post #1116838:
On Sat, Jul 27, 2013 at 5:55 AM, Austin J. <lists@ruby-forum.com> wrote:
"Jes=C3=BAs Gabriel y Gal=C3=A1n" <jgabrielygalan@gmail.com> wrote in pos=
Am 27.07.2013 21:04, schrieb Austin J.:
unknown wrote in post #1116906:
Am 27.07.2013 22:12, schrieb Austin J.:
unknown wrote in post #1116910:
[#409073] class <=> module — Bráulio Bhavamitra <lists@...>
Hello all,
Am 24.07.2013 01:04, schrieb Br叩ulio Bhavamitra:
On Wed, Jul 24, 2013 at 1:10 AM, <sto.mar@web.de> wrote:
Am 24.07.2013 14:35, schrieb Josh Cheek:
[#409104] Ruby newbie question on Methods (NoMethoderror) — "Crispian A." <lists@...>
I have recently started learning ruby and so I am writing a small little
Am 25.07.2013 12:22, schrieb Crispian A.:
unknown wrote in post #1116651:
[#409119] replace words using gsub — noterrain mee <lists@...>
New to ruby! Body is a string, i am using the code directly below. I am
The k is an iterator. Let's use another example here to demonstrate:
[#409134] Learning how to create and save .rbs — Joseph Bershas <lists@...>
So I am trying to create and run an .rb, a basic stepping stone.
[#409139] How to install Ruby 2.0.0 locally - stuck — Thomas Luedeke <lists@...>
I previously installed Ruby 1.8.7 locally on my HP-UX Unix system,
[#409152] Calculate input - numbers — Marc Heiler <lists@...>
Hi
[#409161] Difference between Kernel#caller and Kernel#caller_locations — Love U Ruby <lists@...>
Hi,
[#409169] Love U Ruby — Dave Aronson <rubytalk2dave@...>
On Sat, Jul 27, 2013 at 5:13 PM, Ryan Davis <ryand-ruby@zenspider.com>
On Sun, Jul 28, 2013 at 2:26 AM, Dave Aronson <rubytalk2dave@davearonson.com
[#409170] Working through Ch.10 for learning to program 2.0 (Chris Pine) — JD JD <lists@...>
So, I have been working through this book, and have been doing ok up
I tried this and came up with a one-liner that seems to do it. It sorts the
Am 29.07.2013 16:43, schrieb Harry Kakueki:
On Tue, Jul 30, 2013 at 2:34 AM, <sto.mar@web.de> wrote:
[#409207] Losing values upon converting object to Array — Rochit Sen <lists@...>
Hi All,
[#409221] How to check an input IS an integer ? — Captain Ishido <ishido7@...>
Hi everyone !
[#409225] Question about arrays/hash — Jenn Fo <lists@...>
Hi All:
[#409234] Parsing Data from Row using Regexp — Joel Dezenzio <lists@...>
Hi All,
[#409266] Is there a good port of Ruby for Solaris 10? — Rick Carrick <lists@...>
Does anyone know of a place to DL Ruby for Solaris 10?
[#409267] Method tracker - Need assistance — Kenny Meyer <kenny@...>
I would like to write an includable method tracker, which logs about added
Re: create variables depending on counter
On Fri, Jul 12, 2013 at 9:23 AM, stefan heinrich <lists@ruby-forum.com>wrote:
> > It depends. Where do you get the data from? Is it a fixed set of
> > values? etc.
>
> ok, give me a try to explain. Lets take a look in the Hash
>
I would prefer to look at the input data and see the larger picture.
> {"I OFF"=>["a8", "1e"], "E OFF"=>["98", "a0"], "E ON"=>["db"],
> "I ON"=>["99"]}
>
> The values "a8", "1e", "98" etc. are random generated values. There are
> not fixed but they have an interval. Depending on the value if the LSB =
> 1 it is an ON and LSB = 0 it is a OFF. So normally we can say without
> looking to the syntax
>
> def value_?even(value)
> return :E_ON if value & 0x01
> return :E_OFF
> end
>
Actually, to me it seems there are two values encoded in those Strings you
have above: one is either "I" or "E" and another one is "ON" or "OFF". For
me that means a much more appropriate way to store it would be an instance
with two attributes. You can easily have that with a Struct:
NameOfYourData = Struct.new :whatever_that_means, :enabled do
def self.from_string(s)
raise ArgumentError, "Invalid input: #{s}" unless
/\A(\w+)\s+(O(?:N|OFF))\z/ =~ s
new($1, $2 == "ON")
end
end
irb(main):007:0> x = NameOfYourData.from_string "E ON"
=> #<struct NameOfYourData whatever_that_means="E", enabled=true>
irb(main):008:0> x.enabled
=> true
irb(main):009:0> x.whatever_that_means
=> "E"
Of course you would pick more meaningful names.
But for a ruby newbie it is very difficult and confusing to understand
> symbols in ruby. I have read so much articles and looked for example to
> get it. But I think I need more time to understand symbols.
>
It's fairly easy when to use Symbols: you do that if the set of values is
restricted. In other programming languages you would often use an enum for
that (i.e. a type with a fixed set of values).
> Now what do you suggest me, is it possible to implement this like I
> explained?
>
As I said: without seeing the big picture and understanding what all this
is about and what those different strings represent it's not possible to
come up with good advice. We would need to know
- what the input data looks like
- what it means
- what you want to do with it
- what the whole purpose of the exercise is
Cheers
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/