athinggoingon has quit [Ping timeout: 240 seconds]
darkhex has joined #ruby
nhhagen has joined #ruby
ramfjord has quit [Ping timeout: 264 seconds]
firstdayonthejob has joined #ruby
pietr0 has quit [Quit: pietr0]
tkuchiki has joined #ruby
craysiii has quit [Quit: Leaving.]
fxn has joined #ruby
bubbys has quit [Ping timeout: 246 seconds]
tkuchiki has quit [Ping timeout: 244 seconds]
nhhagen has quit [Remote host closed the connection]
karmatr0n has quit [Ping timeout: 272 seconds]
mikecmpbll has joined #ruby
skinkitten has joined #ruby
yfeldblum has joined #ruby
DLSteve has quit [Ping timeout: 244 seconds]
Zai00 has quit [Quit: Zai00]
Outlastsheep has quit [Ping timeout: 244 seconds]
firstdayonthejob has quit [Read error: Connection reset by peer]
Alina-malina has joined #ruby
ht__ has joined #ruby
Zai00 has joined #ruby
karmatr0n has joined #ruby
nux443 has joined #ruby
bkxd_ has quit [Ping timeout: 244 seconds]
EXID123 has quit [Read error: Connection reset by peer]
Gnomethrower has joined #ruby
karmatr0n has quit [Read error: Connection reset by peer]
<nanoz>
is string interpolation is same as variable substitution ?
Gnomethrower has quit [Changing host]
Gnomethrower has joined #ruby
karmatr0n has joined #ruby
VictorBjelkholm has joined #ruby
djbkd has joined #ruby
bkxd has joined #ruby
howdoicomputer has joined #ruby
yardenbar has quit [Remote host closed the connection]
[k- has joined #ruby
firstdayonthejob has joined #ruby
faces has joined #ruby
face has quit [Ping timeout: 260 seconds]
karmatr0_ has joined #ruby
djbkd has quit [Ping timeout: 250 seconds]
howdoicomputer has quit [Ping timeout: 240 seconds]
karmatr0n has quit [Ping timeout: 240 seconds]
Zai00 has quit [Quit: Zai00]
rezzack1 has joined #ruby
rezzack has quit [Ping timeout: 246 seconds]
<shevy>
guess the two terms would be synonymous
<shevy>
or perhaps variable substitution is the major part of string interpolation
karmatr0_ has quit [Ping timeout: 240 seconds]
baweaver has quit [Remote host closed the connection]
Zai00 has joined #ruby
<jhass>
nanoz: no, string interpolation can take practically any ruby expression
<jhass>
>> "The value of a class expression is the last expression of its body: #{class Foo; :foo_class; end}"
<ruboto>
jhass # => "The value of a class expression is the last expression of its body: foo_class" (https://eval.in/432096)
<jhass>
>> "I guess you can call this one %s" % "variable substitution"
<ruboto>
jhass # => "I guess you can call this one variable substitution" (https://eval.in/432097)
acke has joined #ruby
Averna has joined #ruby
roxtrongo has quit [Read error: Connection reset by peer]
chouhoulis has joined #ruby
VictorBjelkholm has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
dionysus69 has joined #ruby
roxtrongo has joined #ruby
firstdayonthejob has quit [Read error: Connection reset by peer]
chouhoulis has quit [Ping timeout: 260 seconds]
devbug has quit [Read error: Connection reset by peer]
<nanoz>
jhass what about first_name=get.chomp;print "Hello "+first_name ?
<jhass>
that's called "string "+concatenation and "string #{interpolation" is to prefer
<apeiros>
that'd be string concatenation, no substitution happens
<jhass>
}
<nanoz>
k
nhhagen has joined #ruby
karapetyan has joined #ruby
karapetyan has quit [Read error: Connection reset by peer]
pabs has quit [Ping timeout: 246 seconds]
Rutix has joined #ruby
Rutix has joined #ruby
karapetyan has joined #ruby
timonv has joined #ruby
firstdayonthejob has joined #ruby
Jackneill has joined #ruby
karapetyan has quit [Ping timeout: 244 seconds]
DLSteve has joined #ruby
pabs has joined #ruby
<[k->
yes?
<apeiros>
oh k
<[k->
yes?
VictorBjelkholm has joined #ruby
leafybasil has quit [Remote host closed the connection]
EXID123 has joined #ruby
last_staff has quit [Read error: Connection reset by peer]
firstdayonthejob has quit [Read error: Connection reset by peer]
VeryBewitching has quit [Quit: Konversation terminated!]
platzhirsch has joined #ruby
juanpablo_ has joined #ruby
VictorBjelkholm has quit [Client Quit]
charliesome has joined #ruby
<shevy>
finished k
mkosaki has quit [Quit: Leaving...]
eGGsha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
casadei_ has joined #ruby
juanpablo_ has quit [Ping timeout: 252 seconds]
DmitryBochkarev has quit [Quit: This computer has gone to sleep]
<[k->
yes?
VictorBjelkholm has joined #ruby
<shevy>
we have a new bot here
<shevy>
it's always asking yes
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tkuchiki has joined #ruby
casadei_ has quit [Ping timeout: 246 seconds]
firstdayonthejob has joined #ruby
DmitryBochkarev has joined #ruby
<ELCALOR>
hi ya, i want to split integers by 3, in a way that 9 becomes [3, 3, 3], 10 becomes [3, 3, 4] and 11 becomes [4, 4, 3]. anyone knows how i would do this?
<[k->
i've got 9 million 9 hundred 99 thousand 9 hundred 99 tears to go
<[k->
why is 11 [4,4,3]?
yardenbar has joined #ruby
<shevy>
hmmmmm
<[k->
ELCALOR ^
<shevy>
mystery math!
<[k->
i always get ignored :'(
<shevy>
it's your strange nick
MichaelSmith has quit [Quit: Connection closed for inactivity]
pontiki has joined #ruby
<[k->
i dont think when a stranger approaches you out from a crowd, you'd look away and not listen
* shevy
turns his back on [k-
<[k->
especially when s(h)e is talking about something relevant
<[k->
how do you not know s(h)e is talking to you?
charliesome has joined #ruby
<shevy>
dunno, ELCALOR seems very quiet
leafybasil has joined #ruby
<shevy>
ELCALOR a primitive way would be to use .step and gather the results
<[k->
!op(s) my feelings are hurt
<[k->
shevy: but he's results conflict
<[k->
s/he's/his
<shevy>
yeah, the last part is weird
<shevy>
but probably he calculcated it incorrectly in his mind, ruby will yield the proper results!
leat2 has quit [Remote host closed the connection]
<shevy>
[3,3,3,2]
leat2 has joined #ruby
pontiki has quit [Ping timeout: 255 seconds]
<apeiros>
if it'd be consistent (i.e. either 10 -> [4,3,3], 11 -> [4,4,3] OR 10 -> [3,3,4], 11 -> [3,4,4]) it'd be easy. but like this?
* apeiros
too waits for ELCALOR to clear up the inconsistency
EXID123 has quit [Remote host closed the connection]
<[k->
why not 10 -> 3,3,3,1?
<apeiros>
because that'd be 4 values
<apeiros>
not 3
<[k->
ah, thats what he meant
leafybasil has quit [Ping timeout: 272 seconds]
<shevy>
hmm
<shevy>
aha
<apeiros>
and I'd assume (by the pattern) that 10 split 4 -> [2,2,3,3] or [3,3,2,2]
<shevy>
we are better than sherlock holmes here
<apeiros>
I've actually implemented such a code in a production app
EXID123 has joined #ruby
<[k->
for ui?
khebbie has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
leitz has joined #ruby
khebbie has quit [Remote host closed the connection]
<apeiros>
no, for an API call
<apeiros>
the UI allows you to specify how much money you want to invest into a fund
<apeiros>
but the API wants the funds in percentages, the sum of all percentages being 100
<apeiros>
so what do you do when the user specifies 3 funds, and wants to invest 10K in each?
<leitz>
If you're writing a program that uses data in files as a part of it's start up, is there a convention to put those files in a particular directory?
<apeiros>
leitz: GEMDIR/data/GEMNAME/
mprelude has joined #ruby
<apeiros>
Gem.datadir(GEMNAME) gives you the path to that dir, no matter where it gets installed to
Pupeno has joined #ruby
Pupeno has joined #ruby
<shevy>
cool
<leitz>
apeiros, thanks!
<apeiros>
I usually allow the path to be overridden by an env var
<apeiros>
i.e. ENV["GEMNAME_DATA_DIR"] || Gem.datadir(GEMNAME)
leat2 has quit [Remote host closed the connection]
charliesome has joined #ruby
leat2 has joined #ruby
<leitz>
I haven't even gotten it to a gem state yet.. Still learning a lot.
<ELCALOR>
sorry, didn't get any notice of highlights here
<ELCALOR>
apeiros: yeah, that's fine too
<ELCALOR>
sorry [k- ;-(
VictorBjelkholm has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<apeiros>
ELCALOR: well, can you show some code/approaches you tried?
Zai00 has quit [Quit: Zai00]
<ELCALOR>
i first tried to do it with divmod, but didn't work
tkuchiki has quit [Remote host closed the connection]
morenoh149 has joined #ruby
<ELCALOR>
after reading a few times through your function, i'm finally getting it :P
<ELCALOR>
(i reformatted it too)
<apeiros>
sure, you should. it's supposed to be 4 lines.
<jhass>
try giving full names to the single letter vars too
<apeiros>
we use ; instead of newlines in irc to fit it on one line (it works the same with ;)
<ELCALOR>
yep
roxtrongo has quit [Remote host closed the connection]
<apeiros>
ruboto time!
<[k->
ruboto.jump!
monod has quit [Quit: Sto andando via]
ledestin has joined #ruby
pegasuspect has joined #ruby
<apeiros>
more like ruboto.plugins[:channel_moderation].spam("[k-") ;-p
<[k->
yes?
pegasuspect has quit [Client Quit]
<apeiros>
channel moderation is the last plugin to finish in order to switch ruboto to the new foundation.
houhoulis has quit [Remote host closed the connection]
leafybasil has joined #ruby
Pupeno has quit [Remote host closed the connection]
<apeiros>
now if only I remembered where I put those db queries :-(
<shevy>
the resurrection of butler! \o/
wildlander has joined #ruby
osmansekerlen has joined #ruby
Pupeno has joined #ruby
Pupeno has joined #ruby
SCHAAP137 has quit [Quit: Leaving]
VictorBjelkholm has joined #ruby
CorpusCallosum has joined #ruby
fantazo has joined #ruby
acke has quit [Remote host closed the connection]
acke has joined #ruby
bruno- has quit [Ping timeout: 246 seconds]
VictorBjelkholm has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
demonlove has joined #ruby
VictorBjelkholm has joined #ruby
FernandoBasso has joined #ruby
<leitz>
If you have a collection of data points on a "thing", but no methods that really do anything with those points, is an Openstruct better than a class?
<apeiros>
what value would openstruct give you over a class?
<apeiros>
what value would a class give you over openstruct?
<shevy>
method accessors :)
CorpusCallosum has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
howdoicomputer has joined #ruby
<shevy>
for some reason though, I almost always end up defining a custom class instead
ironcamel has quit [Quit: leaving]
<apeiros>
aka "define better"
ironcamel has joined #ruby
<leitz>
Mentally meandering. I have a group of those "things" and the data needs to be printed in different formats. It seemed like the format definition (txt, wiki, html) would not be directly associated with the data/class, but in a calling thing.
ironcamel has quit [Client Quit]
acke_ has joined #ruby
<leitz>
Here's a json collection of data. I'll need to be able to print it out in various formats, and possible remunge it to SQL or something.
acke_ has quit [Remote host closed the connection]
VictorBjelkholm has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<leitz>
Except for "control the output", a struct seems cleaner and less code. If the class had the data, and the output methods, it would gorw organically and perhaps oddly.
stamina has joined #ruby
<leitz>
On use of that file is that another "thing" will be a military unit that is assigned a vehicle. Outputting that will be different than just the vehicle itself.
howdoicomputer has quit [Ping timeout: 252 seconds]
<leitz>
The flip side is tha anything calling that data has to know about it.
acke has quit [Ping timeout: 255 seconds]
acke has joined #ruby
<leitz>
There will be another, similar, dataset for weapons. A person might have a weapon or three, and a unit might have one. And a vehicle.
<shevy>
I wonder why lately the en vogue move is to have "systems programming". Did the prior languages fail at systems programming?
Coldblackice has quit []
<leitz>
Systems are the new thing as we devolve to the IoT, containers, etc.
Rurik has joined #ruby
Rurik has joined #ruby
Rurik has quit [Max SendQ exceeded]
<shevy>
dunno... a lot of it sounds like assigning new names to old(er) ideas and concepts
Rurik has joined #ruby
<leitz>
Yup. Go is a systems programming language. It can do lots of things, but it's targeted at maybe one level closer to the metal.
<leitz>
Ruby is an application programming language; if I have Ruby, pretty much anything underneath is irrelevant.
<shevy>
leitz in regards to your question, I'd probably just use a custom class anyway. A struct may have less code but usually, what is the main difference: accessors, as in def foo; @foo; def foo=(i); @foo = i, for all available datapoints (this is usually a hash isn't it?)
Rurik has quit [Client Quit]
VictorBjelkholm has joined #ruby
dionysus69 has quit [Ping timeout: 250 seconds]
jenrzzz has quit [Ping timeout: 244 seconds]
<shevy>
I use one class Configuration for yaml-based configuration; one internal hash keeps track of what config options are available, then in code I can do something such as: if @configuration.use_readline (or .use_readline?), to enable readline support etc...
<leitz>
Application performance isn't a real need for the app, but i'm trying to learn clean coding as I go.
<leitz>
Of course, my OOP skills are weak. :)
Rurik has joined #ruby
firstdayonthejob has quit [Read error: Connection reset by peer]
drptbl has joined #ruby
Coldblackice has joined #ruby
demonlove has quit [Quit: Leaving]
platzhirsch has quit [Ping timeout: 244 seconds]
bruno- has joined #ruby
pandaant has joined #ruby
leat2 has quit [Remote host closed the connection]
leat2 has joined #ruby
ht__ has quit [Quit: Konversation terminated!]
<[k->
functional!
Rurik has quit [Read error: Connection reset by peer]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Rurik has joined #ruby
beast has joined #ruby
firstdayonthejob has joined #ruby
<leitz>
Well, a hash beats an openstruct. The former has a "has_key?" method that openstruct doesn't.
chouhoulis has joined #ruby
<shevy>
I think you can modify your openstruct object to also include this method
symm- has joined #ruby
<apeiros>
openstruct has respond_to? ;-p
leat2 has quit [Remote host closed the connection]
<leitz>
Interesting, apeiros. I didn't see respond_to/ in the docs page.
<shevy>
anyone knows if there is a trivial way for ruby-ftp to query what commands a remote server responds to? In particular, whether the server understands MLST
user1138 has joined #ruby
user1138 has quit [Remote host closed the connection]
coffeecupp__ has joined #ruby
chouhoulis has quit [Ping timeout: 246 seconds]
solocshaw has joined #ruby
tkuchiki has joined #ruby
dionysus69 has joined #ruby
Averna has quit [Ping timeout: 240 seconds]
dgs has joined #ruby
gizmore has joined #ruby
ironcamel has joined #ruby
<leitz>
Is there a typical name for a collection of functions that go into a library file? Sometime to include in a lot of the other bits, like a method that checks for valid json.
firstdayonthejob has quit [Read error: Connection reset by peer]
dasher00 has quit [Ping timeout: 272 seconds]
<leitz>
Lines 20-27 have a method to check for valid json. It's in a particular file because that's what I was working on when I found the solution on sourceforge.
<leitz>
That's what I have been doing. However, on the off chance someone actually wants to join in, I'd prefer my programs follow the community standard, if there is one.
<leitz>
Except for the Ruby version, of course. ;)
<FernandoBasso>
Why would someone name a method to_s, but not len instead of length?
Averna has quit [Ping timeout: 264 seconds]
casadei_ has joined #ruby
<adaedra>
You usually put functions from a library in a module/class and then require the whole module at once
<[k->
len isnt common in Ruby
devoldmx has joined #ruby
<adaedra>
Don't put functions at top level in a library
juanpablo_ has quit [Ping timeout: 268 seconds]
<FernandoBasso>
[k-: isn't "common"?
<FernandoBasso>
Ruby seems to make things short. def instead of define of function, to_s instead of the lengthier to_string.
ht__ has joined #ruby
bkxd has quit [Ping timeout: 250 seconds]
michael_mbp has joined #ruby
<FernandoBasso>
Then, why not len instead of length, and why not ini or init instead of initialize?
bkxd has joined #ruby
<adaedra>
"seems to make things short" mh, not sure.
<shevy>
leitz I'd first define a toplevel constant, usually a module, sometimes people may opt for a class (like apeiros when he gets naughty)
<adaedra>
clear to read, rather.
<FernandoBasso>
to_s is clearer than to string?
<FernandoBasso>
to_string*
<shevy>
FernandoBasso there already is .size too
<shevy>
so from .size to .len it's only one character less; if you need to do it, you could do: alias len size
<shevy>
note that .to_s is 4 characters :)
<shevy>
there also is .to_str
coffeecupp__ has quit [Remote host closed the connection]
devoldmx has quit [Ping timeout: 240 seconds]
casadei_ has quit [Ping timeout: 260 seconds]
vdamewood has joined #ruby
<leitz>
apeiros has non-naughty times?
Ketchy has joined #ruby
<FernandoBasso>
Yeah, sure, but I don't see the reasoning behind those naming conventions.
<FernandoBasso>
Anyway, this doesn't matter.
firstdayonthejob has joined #ruby
* leitz
goes to read up on modules again.
<FernandoBasso>
Was just curious if someone had an insight about why those two approaches to names.
<shevy>
FernandoBasso same reason you have .collect versus .map
coffeecupp__ has joined #ruby
<shevy>
and you can also use define_method() to define a method
<FernandoBasso>
Aren't those for two different purposes?
dasher00 has joined #ruby
<FernandoBasso>
shevy: I don't meant to approaches -> size vs length.
<shevy>
.map is an alias to .collect (or the other way around, there is usually a link to the source if you look at the official documentation)
<shevy>
size also is an alias to length :)
<FernandoBasso>
I failed to express my thoughts clearly.
Rickmasta has joined #ruby
<FernandoBasso>
I am creating a language. I decide that to_string should be to_s and to_integer should be to_i, and so on. But then I decide that I will not use that "rule" for initialize, neither for length, etc.
firstdayonthejob has quit [Read error: Connection reset by peer]
<FernandoBasso>
Or the decision came from the other way around, I'm not sure.
<FernandoBasso>
They are all very short already, and easy to see what they mean, I'm not complaining about that.
<adaedra>
I don't think the goal is to be short
<FernandoBasso>
Clear?
[k- has quit [Ping timeout: 256 seconds]
<adaedra>
to_#{c} with c being a single char is a common rule for conversion to core type, it's a specialized rule
tkuchiki has joined #ruby
UtkarshRay has joined #ruby
decoponyo has joined #ruby
<shevy>
well you said that they are short, but size is 4 chars, and the to_* are also short, so actually, things are short in ruby!
<shevy>
you could run some statistics on the amount of letters for all methods in default ruby
ruurd has joined #ruby
<shevy>
3 letter variants ... .map ...
<FernandoBasso>
shevy: It seems size was created later on, was it not?
Voker57 has joined #ruby
<shevy>
how do you know
startupality has joined #ruby
<FernandoBasso>
I don't :)
<FernandoBasso>
It just looks like, since it is an alias.
<shevy>
you could try to check the ancient ruby versions
<shevy>
and they can not add both the original name, and the alias, at the same time???
Rurik has quit [Read error: Connection reset by peer]
charliesome has joined #ruby
devoldmx has joined #ruby
<blik71>
shoot is there any alternative to debugging in ruby then I'm quite new to ruby and need to finish a project in it
solocshaw has quit [Ping timeout: 244 seconds]
karapetyan has joined #ruby
chills42 has quit [Remote host closed the connection]
ruurd has joined #ruby
<godfat>
i think the current one is byebug
_aeris_ has joined #ruby
<Burgestrand>
blik71: you are running ruby 1.9.3?
<Burgestrand>
blik71: (run 'ruby -v' to find out)
<blik71>
yes
<blik71>
1.93p484
solocshaw has joined #ruby
<adaedra>
1.9.3 is EOL
<Burgestrand>
blik71: it's possible that pry still works on 1.9.3 if you're having issues with ruby-debug, if it will help you kind of depends on what you are debugging
<blik71>
EOL?
VictorBjelkholm has joined #ruby
<adaedra>
End-of-life
<blik71>
shiit
<adaedra>
In short: Update.
<Burgestrand>
blik71: 1.9.3 is no longer receiving security updates and is considered old
<blik71>
this is the one my school is using i believe but let me check
<karapetyan>
shevy: feel like a rabbit
<Burgestrand>
blik71: if you're doing a one-off project for your school you don't necessarily need to upgrade your ruby, but if you plan on having your project alive once you're done with it you should use something newer.
<shevy>
karapetyan yeah
<shevy>
blik71 you can use ruby 1.9.3 without ruby-debug can't you? :)
<karapetyan>
shevy: shit that's not so simple as i thought...
<shevy>
...
DoubleMalt has joined #ruby
<blik71>
I mean I can but I'm stuck in that my code is doing something weird and I don't know what is going on
<Burgestrand>
blik71: I would recommend you try using "pry". General instructions: install the gem ("gem install pry"), in the code you're confused about do 'require "pry"' somewhere at the top, and then insert the line "binding.pry" where you want to peek around to get a better idea of what is happening.
<Burgestrand>
blik71: it will open an interactive interpreter where you can print out local variables and try to figure out what's happening.
khebbie has joined #ruby
khebbie has quit [Remote host closed the connection]
khebbie has joined #ruby
chills42 has joined #ruby
osmansekerlen has joined #ruby
khebbie has quit [Remote host closed the connection]
drptbl has quit [Quit: My MAC has gone to sleep. zZz..]
<Balzrael>
binding.pry is da bomb when debugging ruby code
<Balzrael>
and if you have rubymine as your editor of choice or intellij it comes already with a nice debugger
tkuchiki has quit [Remote host closed the connection]
<blik71>
oh wow this is cool thank you sooo much :DDD!
Contigi has joined #ruby
<shevy>
karapetyan your code must become clear in its intent
startupality has quit [Quit: startupality]
<Balzrael>
just type q to be able to issue commands and write code at that point in the source file
<Balzrael>
also you have step and next as commands
<Balzrael>
and all the other goodies from a debugger that I don't really know how they work :)
<karapetyan>
shevy: i trying to split it in simple modules
chills42 has quit [Remote host closed the connection]
startupality has joined #ruby
skinkitten has quit [Ping timeout: 255 seconds]
<Balzrael>
I just inspect my objects to find the problem and run some methods
<Balzrael>
do (x[2+x] == nil) ? ...
Burgestrand has quit []
Burgestrand has joined #ruby
pontiki has joined #ruby
<blik71>
wait how do advance through or do I have to put itafter the code i want to inspect
devoldmx has quit [Remote host closed the connection]
DoubleMalt has quit [Remote host closed the connection]
<Balzrael>
after you typed q and inspected the obeject from the console and run some code you can type step or next to advance to the next point in the execution
shmilan has joined #ruby
<Burgestrand>
blik71: by default there's no way to advance the program in pry, you just have to put the binding.pry in multiple places
Rickmasta has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Balzrael>
it has setep and next commands but I never used them
<Balzrael>
as most other Ruby devs :)
karapetyan has quit [Remote host closed the connection]
<Balzrael>
just add more binding.pry
<Burgestrand>
There's no step, unless you're using a debugging plugin with pry.
<Burgestrand>
i.e. byebug
<Balzrael>
next is good for incremental line execution
<Burgestrand>
There's no next.
pawnbox has joined #ruby
<Balzrael>
well get a debugging pry based gem then
arup_r has joined #ruby
<Burgestrand>
blik71: like Balzrael mentions, if you want to advance without sprinkling binding.pry all over the place, you could use 'pry-stack_explorer' (https://github.com/pry/pry-stack_explorer), it's compatible with Ruby 1.9
juanpablo_ has joined #ruby
<ocx>
hello, any summary of difference between javascript objects and ruby objects?
<Burgestrand>
ocx: everything
<Burgestrand>
;)
leat2 has quit [Ping timeout: 244 seconds]
kirun has joined #ruby
<Burgestrand>
ocx: do you have something more specific?
<ocx>
Burgestrand: i am coding in both languages and trying to come up with a summary
<ocx>
to clear up my mind
chouhoulis has joined #ruby
<ocx>
in javascript i define an object as { } in ruby i just define a var and it is a generic object?
<ocx>
the generic object can be a number, a hash , an array everything?
<Burgestrand>
ocx: I'm not sure there's a way to make a good summary without it turning into multiple sentences, at least.
<Burgestrand>
ocx: in Ruby everything is an object (more or less), in JavaScript you also have primitives (numbers, strings) that are not objects.
<ocx>
yea so in ruby even a number has a built in function
<Burgestrand>
ocx: however, both languages can be written so their usage looks very very similar, even though it's actually different ideas down below.
<ocx>
in havascript it is not the case a number is primitive
startupality has quit [Quit: startupality]
khebbie has joined #ruby
khebbie has quit [Remote host closed the connection]
<ocx>
Burgestrand: for example in javascript you have the dynamic linking where you inject scopes, and functions into other functions , do you have this in ruby too?
<Burgestrand>
ocx: yes, there's a way to do it, and it's not uncommon.
juanpablo_ has quit [Ping timeout: 265 seconds]
casadei_ has joined #ruby
<Burgestrand>
ocx: in javascript, there's "this", and in ruby there is "self", they are similar but not the same, and have different rules.
<ocx>
i do vat self = this in javascript
<Burgestrand>
ocx: in javascript you can control this using Function#apply and Function#call, in Ruby you can do it using #instance_exec, and similar methods.
<ocx>
Burgestrand: do you have an mvc model in ruby?
<ocx>
model view controller?
<ocx>
for example in angular that is used
<Burgestrand>
ocx: MVC is not a language-specific thing.
chouhoulis has quit [Ping timeout: 264 seconds]
<Burgestrand>
ocx: it's a pattern, just like Math is not something you don't have in some languages.
<Burgestrand>
ocx: an idea, so to speak.
<ocx>
mvc is not adpoted a lot in ruby i think since you are dealing with backends
rbennacer has joined #ruby
<Burgestrand>
ocx: Rails claims to be MVC.
<Burgestrand>
ocx: And frankly, the thought of MVC is older in Ruby than JavaScript. Back before the front-end frameworks came, MVC was the hot thing in back-end development.
<Burgestrand>
In my opinion it wasn't necessarily MVC, but people like easy ways to communicate what they're doing so it was adopted.
<Aeyrix>
Rails isn't mvc?
<ocx>
Burgestrand: let me guess , in rails the M is the SQL or the rails internal variables, V is apache or where users connect and C is the lofic inside rails?
<Burgestrand>
ocx: In short, Ruby has MVC, and it was popular in Ruby before it was popular in JavaScript, but it's not a fair comparison to make when you're putting languages in front to compare them.
casadei_ has quit [Ping timeout: 250 seconds]
<Aeyrix>
ocx: what
<jgt>
ocx: you're either trolling, or you've been dealt an entire mountain of misinformation
<Aeyrix>
... what the fuck
<Aeyrix>
yeah
<jgt>
MVC not adopted because backends? WHAT!?
<Burgestrand>
I think this reaction is not proportional to the question.
<Burgestrand>
ocx: Rails considers the V as the model of something that is sent to the client, most often HTML.
<Aeyrix>
I...
<Burgestrand>
ocx: The M tends to be the database layer, the ORM, but it's not necessarily database-connected, it could as well be domain logic.
<Aeyrix>
I'm really glad
<Aeyrix>
that
<Aeyrix>
you're not talking about this in #ror
<Aeyrix>
where you could be misinforming people who actually want to learn about rails
<jgt>
when I read stuff like this, I think of the eloquent words of Steve Losh: “Stop reading Hacker News, and open a fucking book”
<Aeyrix>
Pretty much fam.
<Burgestrand>
ocx: C is what handles the request.
<ocx>
sorry then
<shevy>
we shall master C
tkuchiki has joined #ruby
<Aeyrix>
mods mods mods
<Burgestrand>
ocx: Keep in mind that this is not the traditional MVC as it was written in the 80s.
<Aeyrix>
mods mods mods
poli has joined #ruby
<ocx>
C handles the request from Apache?
<Burgestrand>
ocx: C is what decides how the request is handled, yes.
chills42 has joined #ruby
<Burgestrand>
ocx: the flow goes Browser -> Apache -> C -> M (maybe multiple) -> V -> HTML -> Browser.
<jgt>
Burgestrand: that responsibility is also kinda sorta divided with a router
<Burgestrand>
jgt: Yes.
CorpusCallosum has joined #ruby
<jgt>
but yeah, the flow above is totally correct
<Burgestrand>
Like all generalisations this is not entirely correct, but it's a good approximation.
<blik71>
thank you for suggesting pry that fixed my problem, also doesnt chomp take off the last specified character such as a ","
<Burgestrand>
blik71: :)
spencer6245_ has joined #ruby
chills42 has quit [Remote host closed the connection]
<jeanlinux>
but here is the thing.. i want to keep the connection the the beanstalkd server alive always .. so i can receive new jobs almost instantaneously
FernandoBasso has joined #ruby
<jeanlinux>
any suggestion on how to achieve that, cron, rails task, or rails 4 Live streaming? which would be more effective
<jeanlinux>
sorry this is rails specific.. but i am a little bit stuck on this
umgrosscol has joined #ruby
dac has joined #ruby
dac is now known as Guest7866
tmtwd has joined #ruby
dcarmich has joined #ruby
araujo_ has joined #ruby
DmitryBochkarev has joined #ruby
tkuchiki has joined #ruby
<Yzguy>
heyoo
dcarmich has quit [Client Quit]
araujo_ has quit [Client Quit]
araujo has joined #ruby
howdoicomputer has joined #ruby
jdawgaz has joined #ruby
Guest7866 is now known as Dack
howdoicomputer has quit [Ping timeout: 255 seconds]
Dack is now known as Dacky
nanoz has quit [Ping timeout: 256 seconds]
chouhoulis has joined #ruby
skade has joined #ruby
<Yzguy>
anyone have experience with sinatra?
Musashi007 has quit [Quit: Musashi007]
khebbie has joined #ruby
khebbie has quit [Remote host closed the connection]
tkuchiki has quit [Remote host closed the connection]
karapetyan has joined #ruby
roxtrongo has joined #ruby
athinggoingon has joined #ruby
jdawgaz has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ordepdev has joined #ruby
Llama4146 has joined #ruby
karapetyan has quit [Ping timeout: 268 seconds]
dionysus69 has quit [Ping timeout: 240 seconds]
roxtrongo has quit [Ping timeout: 252 seconds]
leitz has quit [Ping timeout: 246 seconds]
kalzz has joined #ruby
kalz has joined #ruby
karmatr0n has joined #ruby
rbennacer has quit [Remote host closed the connection]
phutchins has joined #ruby
Zackio has quit [Read error: Connection reset by peer]
ordepdev has quit [Remote host closed the connection]
stamina has quit [Ping timeout: 250 seconds]
leat2 has joined #ruby
havenwood has joined #ruby
Zackio has joined #ruby
deavid has quit [Ping timeout: 260 seconds]
LiquidInsect has quit [Read error: Connection reset by peer]
LiquidInsect has joined #ruby
karmatr0n has quit [Read error: No route to host]
karmatr0_ has joined #ruby
haxrbyte has joined #ruby
khebbie has joined #ruby
khebbie has quit [Remote host closed the connection]
Zai00 has joined #ruby
ordepdev has joined #ruby
MVPhelp has quit [Remote host closed the connection]
pawnbox has joined #ruby
tkuchiki has joined #ruby
karmatr0_ has quit [Read error: No route to host]
shinnya has joined #ruby
karmatr0n has joined #ruby
skade has quit [Quit: Computer has gone to sleep.]
mary5030 has joined #ruby
MVPhelp has joined #ruby
deject3d has quit [Quit: Computer has gone to sleep.]
frog0909 has joined #ruby
ordepdev has quit [Ping timeout: 240 seconds]
krz has joined #ruby
solocshaw has quit [Remote host closed the connection]
solocshaw1 has joined #ruby
nhhagen has quit [Remote host closed the connection]
solocshaw1 is now known as solocshaw
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
nhhagen has joined #ruby
nhhagen has quit [Remote host closed the connection]
deavid has joined #ruby
leitz has joined #ruby
karmatr0n has quit [Ping timeout: 250 seconds]
Zackio has quit [Read error: Connection reset by peer]
ht__ has quit [Quit: Konversation terminated!]
codecop has joined #ruby
haxrbyte has quit [Quit: Leaving...]
jenrzzz has joined #ruby
ruurd has joined #ruby
astrobunny has joined #ruby
morenoh149 has joined #ruby
futilegames has joined #ruby
phutchins has quit [Ping timeout: 240 seconds]
jamesaxl has joined #ruby
pwnd_nsfw has joined #ruby
jenrzzz has quit [Ping timeout: 255 seconds]
karmatr0n has joined #ruby
ndrei has quit [Ping timeout: 240 seconds]
KramerC has quit [Quit: Leaving]
KramerC has joined #ruby
morenoh149 has quit [Ping timeout: 255 seconds]
karmatr0n has quit [Read error: No route to host]
DLSteve has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
futilegames has quit [Client Quit]
jcoe has joined #ruby
karmatr0n has joined #ruby
tkuchiki has quit [Remote host closed the connection]
minotep has joined #ruby
DmitryBochkarev has quit [Ping timeout: 252 seconds]
DmitryBochkarev has joined #ruby
casadei_ has joined #ruby
DLSteve has joined #ruby
karmatr0n has quit [Ping timeout: 240 seconds]
n1lo has joined #ruby
dasher00 has quit [Quit: Leaving]
tkuchiki has joined #ruby
karmatr0n has joined #ruby
minotep has quit [Ping timeout: 272 seconds]
Oka has joined #ruby
dasher00 has joined #ruby
karapetyan has joined #ruby
casadei_ has quit [Ping timeout: 250 seconds]
fantazo has joined #ruby
Zai00 has quit [Quit: Zai00]
k3asd` has joined #ruby
Azure|dc has quit [Ping timeout: 246 seconds]
tkuchiki has quit [Remote host closed the connection]
chouhoulis has joined #ruby
izhak has joined #ruby
arup_r has quit [Ping timeout: 264 seconds]
<shevy>
#sinatra should have
ekain has joined #ruby
<izhak>
Hi, guys! Is it possible to wrap a missing (but callable) method to a reference. I mean, is it possible to return a reference to a missing method like .method(:some_real_method) does?
juanpablo_ has joined #ruby
bkxd has quit [Ping timeout: 265 seconds]
<shevy>
wat
<shevy>
return a reference to something that does not exist?
Llama4146 has quit [Read error: Connection reset by peer]
nanoz has joined #ruby
karmatr0n has quit [Remote host closed the connection]
<shevy>
pay pizza with invisible money :)
mleung has joined #ruby
s00pcan has joined #ruby
karmatr0n has joined #ruby
osmansekerlen has quit [Quit: osmansekerlen]
<izhak>
shevy: Why not? If you can call smth that doesn't exist, why can't you just reference it?
yeticry has quit [Ping timeout: 272 seconds]
nowhereFast has joined #ruby
<shevy>
ah you are the webchat guy
karmatr0n has quit [Read error: Connection reset by peer]
karmatr0n has joined #ruby
juanpablo_ has quit [Ping timeout: 250 seconds]
<nowhereFast>
how would I do a when i % 2 == 0 in a case statement?
pontiki has quit [Ping timeout: 265 seconds]
yeticry has joined #ruby
elperdut has joined #ruby
<centrx>
nowhereFast, like that works
<centrx>
nowhereFast, there are two forms of case
<nowhereFast>
then I must be buckling something
roxtrongo has joined #ruby
<shevy>
you could check-case on the result, such as case (i % 2); when 0; when 1
<nowhereFast>
is there a specific pastebin that is preferred?
<shevy>
yeyh you can put it on the case line as shown above
youngbaks has quit [Ping timeout: 246 seconds]
<nowhereFast>
except that example doesnt work
roxtrongo has quit [Ping timeout: 264 seconds]
<izhak>
nowhereFast: if this is the only condition (yes or no) it's better to use _if_. Otherwise, if you need to use _case_ then just omit _i_ after _case_
<nowhereFast>
lets assume I'm going to be adding cases
dionysus69 has joined #ruby
<centrx>
actually not great link
bruno- has quit [Ping timeout: 244 seconds]
<izhak>
nowhereFast: just omit _i_ after _case_
<nowhereFast>
pretty much just started with ruby so looking to make sense of its 'flow'
leat2 has quit [Ping timeout: 265 seconds]
<shevy>
nowhereFast listen to centrx, don't listen to izhak :)
<nowhereFast>
heh
<centrx>
All hail shevy
leat2 has joined #ruby
solocshaw has quit [Ping timeout: 256 seconds]
<shevy>
if it helps, you could check the return value in a variable
fantazo_ has joined #ruby
<nowhereFast>
there must be a dirty harry quote somewhere in there
<shevy>
and then use: case variable on that result
<nowhereFast>
right, so dropping the i on the case line does it... now I've just got to figure out why
r_baron has joined #ruby
<shevy>
can you update your gist, to reflex your current code?
* nowhereFast
looks at the not great link
<shevy>
*reflect
sumark has quit [Remote host closed the connection]
<shevy>
you can also save with .rb ending on gist, then you get automatic colour highlighting for ruby
<izhak>
nowhereFast: all _when_ conditions considered one by one, if one evaluates to true, this block will be executed
ht__ has joined #ruby
sumark has joined #ruby
zenguy_pc2 has quit [Read error: Connection reset by peer]
<nowhereFast>
okay, just not seeing the value to the 'case' keyword as it currently stands
<nowhereFast>
not with the when's in there
esauOp has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<nowhereFast>
case when when when, -it looks a little like nested cases
zenguy_pc2 has joined #ruby
fantazo_ has quit [Quit: Verlassend]
<izhak>
when you specify an expression after _case_, then _when_ checks for equality of the _case_ expression and _when_ expression and if they are equal executes that block
<centrx>
nowhereFast, case is very similar to a series of if-else statements
<centrx>
nowhereFast, it's more concise and clean in some cases
zenguy_pc2 has quit [Max SendQ exceeded]
zenguy_pc2 has joined #ruby
<shevy>
nowhereFast can you show your current code on gist?
<nowhereFast>
yes, about as concise as switch is in general, im mentally comparing to scala's pattern matching I suppose
<nowhereFast>
shevy... all I did was as izhak and centrx both suggested and took the i off the case line
zenguy_pc2 has quit [Max SendQ exceeded]
karapetyan has quit [Remote host closed the connection]
zenguy_pc has joined #ruby
zenguy_pc has quit [Read error: Connection reset by peer]
karapetyan has joined #ruby
amoeba_ has joined #ruby
Soda has quit [Remote host closed the connection]
xcesariox has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zenguy_pc has joined #ruby
amoeba_ has quit [Client Quit]
amoeba_ has joined #ruby
solocshaw has joined #ruby
amoeba_ has quit [Client Quit]
zenguy_pc has quit [Max SendQ exceeded]
djbkd has joined #ruby
<nowhereFast>
having multiple when statements, -is there a way to execute a block of code regardless of which condition is met?
<gizmore>
nowhereFast: maybe doit = true; case.... else doit = false; ... and then an if doit below
deject3d has quit [Remote host closed the connection]
amoeba_ has joined #ruby
karapetyan has quit [Remote host closed the connection]
leat2 has quit [Remote host closed the connection]
stardiviner has quit [Quit: Code, Sex, Just fucking world.]
<nowhereFast>
yup, an additional check, I was looking to see if there was something like a 'regardless' of sorts
ruurd has quit [Quit: ZZZzzz…]
vigo has joined #ruby
djbkd has quit [Ping timeout: 265 seconds]
leat2 has joined #ruby
<vigo>
hi gizmore
<izhak>
nowhereFast: you can just merge _when_ conditions with comma
amoeba has quit [Disconnected by services]
amoeba has joined #ruby
amoeba has quit [Disconnected by services]
amoeba_ is now known as amoeba
amoeba` has joined #ruby
quanzhuo has joined #ruby
phreakocious has quit [Ping timeout: 255 seconds]
quanzhuo has left #ruby [#ruby]
DLSteve has quit [Ping timeout: 244 seconds]
fantazo has quit [Quit: Verlassend]
sankaber has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<nowhereFast>
izhak, got a link for that merging?
<shevy>
when 1,2,3,4,5
<izhak>
yeah.. It'll act like any of with both _case_ types.
<apt-get>
is there any easy way to get the default browser's name?
<shevy>
apt-get it's usually stored somewhere or sent via http isn't it?
<apt-get>
shevy: what do you mean?
acke has quit [Remote host closed the connection]
DLSteve has joined #ruby
phreakocious has joined #ruby
jacksonmills has joined #ruby
<nowhereFast>
apt-get, your http headers will have that info
craysiii has joined #ruby
leat2 has quit [Remote host closed the connection]
leat2 has joined #ruby
ruurd has joined #ruby
<nowhereFast>
when the browser connects in the handshake process it tells the server the who and what it is
jenrzzz has joined #ruby
apt-get_ has joined #ruby
<apt-get_>
sorry for leaving, connection problems.
<apt-get_>
anyway, shevy, I'm not talking about using a web framework
<apt-get_>
meant more inside of a script
<nowhereFast>
the when's in cases are mutually exclusive if not merged? -so if one when is met the rest are not processed?
apt-get has quit [Ping timeout: 246 seconds]
<nowhereFast>
246 seconds ping... crazy
<izhak>
nowhereFast: right. The first one will win
<amoeba>
apt-get_: in linux you can do: xdg-settings get default-web-browser
<amoeba>
not sure how portable that is
elperdut has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<nowhereFast>
izhak... do you know if ruby runs through them though regardless on if a condition is met?
<nowhereFast>
asking more from an efficiency perspective, some languages actually process on regardless making case runs slower
leat2 has quit [Ping timeout: 260 seconds]
<izhak>
nowhereFast: I would think it evaluates them until first true is met
jenrzzz has quit [Ping timeout: 272 seconds]
jgt has joined #ruby
<nowhereFast>
:-) one would think that would do this
<nowhereFast>
all*
<amoeba>
nowhereFast: I imagine it depends on the number of conditions
Yzguy has quit [Quit: Zzz...]
leat2 has joined #ruby
<izhak>
it would be a serious problem it ruby would evaluate them all.. it changes logic, and has side effects. So it shouldn't be depend on number of conditions
karmatr0n has joined #ruby
leat2 has quit [Remote host closed the connection]
<apt-get_>
amoeba: I guess that works
modern has joined #ruby
leat2 has joined #ruby
<apt-get_>
but a windows solution would be nice too... :/
<amoeba>
not sure, but I bet it's a registry value somewhere
<izhak>
For static case expressions like in C, where switch values are compile time, it's possible to use hashes, jump tables etc.
phreakocious has joined #ruby
karmatr0n has quit [Ping timeout: 244 seconds]
jgt has quit [Quit: WeeChat 1.2]
ndrei has joined #ruby
Trieste has joined #ruby
jgt has joined #ruby
ruurd has quit [Quit: ZZZzzz…]
<amoeba>
izhak, yeah expression that mutate state prevents it... I imagine there could be optimization if the expressions were static, but this is one of those things were it probably doesn't matter much.
Neverdie has joined #ruby
WajidKagzi has joined #ruby
<nowhereFast>
I dont think the article was referring to optimizing _when_ as much as it was referring to interpreted languages being slower in general, and that if the detail mattered you'd be better off going a different route
karmatr0_ has quit [Ping timeout: 246 seconds]
ordepdev has joined #ruby
DmitryBochkarev has quit [Ping timeout: 240 seconds]
futilegames has joined #ruby
astrobunny has quit [Remote host closed the connection]
queequeg1 has joined #ruby
firstdayonthejob has joined #ruby
<izhak>
yes, generally any IFS are evil for superscalar archs, cause they use predictions and conveyor heavily, and when a line of execution can't be predicted they suffer speed degradation, as whole prefetched line should be reset. That's why all dynamic cases are by definition slow.
stamina has joined #ruby
[k- has joined #ruby
QORRiE has joined #ruby
<izhak>
where slow means "shouldn't be used in cycles" :)
<nowhereFast>
yup, the use case should dictate though, and I think dynamic languages these days hold their own just fine in the majority of cases
ordepdev has quit [Remote host closed the connection]
ordepdev has joined #ruby
<nowhereFast>
x = "blah"; x[0] #returns b
<nowhereFast>
x = 123; -how do I get the 0'th index here?
<nowhereFast>
and to have it return as a number x.to_s[0].to_i?
<[k->
please use proper terms...
firstdayonthejob has quit [Read error: Connection reset by peer]
Blaguvest has joined #ruby
rehat has joined #ruby
<[k->
use hundreds place or something to make your questiom clearer
<[k->
but you are right
<shevy>
nowhereFast yes, usually via []
solocshaw has quit [Ping timeout: 244 seconds]
<[k->
shevy you ignore me too :(
solocshaw has joined #ruby
<shevy>
your nick is so tiny!
QORRiE has quit [Changing host]
QORRiE has joined #ruby
<shevy>
xchat displays a vertical | after a nick
DmitryBochkarev has joined #ruby
<shevy>
so your nick appears like |k|
<[k->
but there is still a line!
<[k->
do you not notice the lines???!
<shevy>
random-hit-enter key
<shevy>
:)
<[k->
:(
umgrosscol has quit [Remote host closed the connection]
<rehat>
if I have a path string to a file and I want to remove the '.<extention>' at the end would I use slice minus the last two characters or is there a better way
karmatr0n has quit [Read error: Connection reset by peer]
<[k->
Scala?
karmatr0n has joined #ruby
hanmac has joined #ruby
jgt has quit [Ping timeout: 268 seconds]
cornerman has quit [Ping timeout: 240 seconds]
juanpablo_ has joined #ruby
cornerma1 is now known as cornerman
jdawgaz has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<shevy>
ocaml
<shevy>
I don't know the difference anyway
<FernandoBasso>
"To use the assignment method you must set the receiver." def my_method=(val) self.some_var = val; end <-- This gives me an error.
<FernandoBasso>
Also, is the assignment method = or my_method= ?
pontiki has joined #ruby
casadei_ has joined #ruby
leat2 has quit [Ping timeout: 265 seconds]
karmatr0n has quit [Ping timeout: 240 seconds]
howdoicomputer has joined #ruby
houhoulis has joined #ruby
<gizmore>
is there any working skype api? ... like there is webapi now, and some universal communication for skype... but the docs are horrible... is there maybe a ruby gem that works already?
juanpablo_ has quit [Ping timeout: 240 seconds]
newdan has joined #ruby
tejasmanohar has joined #ruby
<[k->
Fernando, try @some_var =
<shevy>
FernandoBasso use foo=(i) rather than foo =(i)
<newdan>
Is there a shorthand for ["foo", "bar"].map {|s| URI.decode(s))}
arup_r has joined #ruby
<shevy>
in your example, the = belongs to the method invocation, the ruby parser just is liberal
<newdan>
I know in Python I'd be able to do something like map(URI.decode, ['foo', 'bar'])
<[k->
%w[foo bar]
<newdan>
[k-: Haha that's not the part I'm looking to shorthand, I mean is there a way to change that block so I can just "reference" URI.decode and give that to map()?
symm- has joined #ruby
casadei_ has quit [Ping timeout: 244 seconds]
<[k->
URI.method(:decode)?
<[k->
im not sure if that works though
<shevy>
newdan unfortunately ruby does not allow shorthand notation with arguments via &
karmatr0n has joined #ruby
howdoicomputer has quit [Ping timeout: 250 seconds]
sankaber has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<shevy>
would be nice if one could do %w( foo bar ).map(&:URI.decode(&input))
<[k->
&URI.method(:decode)
ekleog has quit [Remote host closed the connection]
<newdan>
Still learning Ruby. My train of thought was e.g. %[foo bar].map &:upcase works pretty well, was wondering if there'd be something like that if I was using URI.decode instead
<newdan>
But the block's not too bad
<shevy>
yeah but your example works because you don't pass an argument
<shevy>
you just call .upcase
milanpaperclip has joined #ruby
northfurr has quit [Quit: northfurr]
<shevy>
perhaps in ruby 3.0!
lxsameer has quit [Ping timeout: 264 seconds]
dionysus69 has joined #ruby
<newdan>
shevy: Sounds good :) Also helps me feel less like I'm doing it wrong now
<craysiii>
isn't ruby passing each element of the array as an argument to the block as it's yielded?
<shevy>
in the {} variant sure
northfurr has joined #ruby
<ytti>
if you want in this gang, you gotta love blocks
<craysiii>
%[foo bar].map &:upcase < not in this case?
<ytti>
it's our gang sign
<baweaver>
Symbol to proc
<craysiii>
%w{ west side }
<shevy>
craysiii well, you don't pass an argument to upcase()
<baweaver>
same thing
<newdan>
AFAIK the ampersand is the same as (:upcase.to_proc).('foo')
<FernandoBasso>
I would -guess- the first one returns 55.
karmatr0n has quit [Read error: No route to host]
karmatr0n has joined #ruby
<FernandoBasso>
But I know JS, for instance, ignores certain return types in certain situations.
nowhereFast has quit [Client Quit]
<FernandoBasso>
If you call a constructor function and return something that is not an object, explicit return is simply ignored, and the newly created object is returned anyway.
<shevy>
yeah
<shevy>
first one returns 42, second one 55
<shevy>
note that the only real difference is the =
jackjackdripper has quit [Quit: Leaving.]
<shevy>
sounds similar to ruby
<shevy>
the explanation I was given was that code like this works: foo.x = foo.y = foo.z = 1
juanpablo_ has joined #ruby
<FernandoBasso>
Ok, I think I see.
<FernandoBasso>
But I don't know if i accept that I am unable to learn from the docs, or the docs are just too superficial...
<FernandoBasso>
Or both :p
mleung has joined #ruby
<shevy>
dunno
<shevy>
I write down stuff into my own local docu
mleung has quit [Client Quit]
jeanlinux has quit [Read error: Connection reset by peer]
firstdayonthejob has joined #ruby
mistermocha has quit [Remote host closed the connection]
juanpablo_ has quit [Ping timeout: 244 seconds]
<FernandoBasso>
In my earlier example, although def name=(name); self.name = name; end did not work, a method with another name accepted self.name.
<FernandoBasso>
shevy: Me too.
<FernandoBasso>
Anki, also.
<shevy>
yeah because you were recursively calling the method
<FernandoBasso>
Makes sense.
ebbflowgo has joined #ruby
nowhereFast has joined #ruby
<FernandoBasso>
shevy: Thanks a lot for this invaluable lesson.
pawnbox has quit [Ping timeout: 250 seconds]
rakm has joined #ruby
<shevy>
\o/
<FernandoBasso>
I was able to contribute to some MDN docs (very few things). PHP is hell to contribute to the docs.
mleung has joined #ruby
Alina-malina has quit [Ping timeout: 244 seconds]
Narzew has quit [Quit: Leaving]
<FernandoBasso>
If ruby is easy to contribute to docs, you could consider making some contributions like this from time to time :p
jeanlinux has joined #ruby
Zackio has joined #ruby
<FernandoBasso>
I will try if one day I fell I know what I am talking about.
dasher00 has quit [Ping timeout: 246 seconds]
roxtrong_ has joined #ruby
Alina-malina has joined #ruby
mistryneel has joined #ruby
<FernandoBasso>
Anyway, thanks once more. I really appreciate you spending time helping others out. Honorable.
<rehat>
regex question. how do you use a character class to capture and ignore at the same time? Trying to avoid capturing the IBAction here http://rubular.com/r/IjLpZOYd8z
dotix has quit [Ping timeout: 240 seconds]
<newdan>
Is Python overtaking PHP popularity? I thought Ruby/Rails was what took it over
<karapetyan>
shevy: rabbbbbiitss :$
nowhereFast has left #ruby [#ruby]
<shevy>
newdan python yeah, ruby-rails not really
centrx has quit [Quit: "You cannot fix a machine by just power-cycling it with no understanding of what is going wrong."]
VeryBewitching has joined #ruby
dasher00 has joined #ruby
allomov has quit [Remote host closed the connection]
nowhereFast has joined #ruby
mistryneel has quit []
karmatr0_ has joined #ruby
BraddPitt has joined #ruby
crankhar1er has joined #ruby
<FernandoBasso>
shevy: I will show you my boss' php code (only a tiny portion of it).
BraddPitt has quit [Client Quit]
BraddPitt has joined #ruby
karapetyan has quit [Remote host closed the connection]
<FernandoBasso>
There are at least 5 bad practices in those few lines.
<FernandoBasso>
7 nested ifs, to start with.
<shevy>
isn't this brilliant?
<shevy>
function print_custom_reduced_alphabet_info(){
<shevy>
?>
<shevy>
I really dig this
<FernandoBasso>
haha!
<weaksauce>
rehat what exactly are you trying to accomplish?
karmatr0n has joined #ruby
elperdut has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<rehat>
trying to get all methods in a objective-c file but avoid methods with the IBAction return type
<FernandoBasso>
shevy: But seriously, like in that sentence "just because javascript is classless, it doesn't mean you have to", one doesn't need to write such code in php either.
crankharder has quit [Disconnected by services]
karmatr0_ has quit [Ping timeout: 244 seconds]
crankhar1er is now known as crankharder
<shevy>
I think javascript is a better programming language compared to php
<FernandoBasso>
gravar1_1(), gravar1_2, gravar2_1, etc, magic numbers, unsanitized data to db, direct access to globals, and many other bad things.
<FernandoBasso>
shevy: Me too.
<FernandoBasso>
I actually like js.
<rehat>
I guess I could filter that out later, but it would be cool to know how to do it with a regex pattern
<FernandoBasso>
I like almost all langs.
shinnya has quit [Ping timeout: 260 seconds]
<FernandoBasso>
(from the ones I had contact so far)
krz has quit [Ping timeout: 250 seconds]
jeanlinux has quit [Ping timeout: 244 seconds]
<weaksauce>
rehat i don't think it's really possible with regex. might be but it's not great at rejecting things
ordepdev has joined #ruby
<weaksauce>
it's meant for regular expressions that have a regular structure.
<FernandoBasso>
shevy: And we all know PHP is not php4.x any longer anyway.
<rehat>
weaksauce: ahh, ok thanks
xiii_ has joined #ruby
<xiii_>
I have a binary string (like "010111000101010101"). How do I convert this to raw text in Ruby?
<mblagden_>
you want the ascii values of the 0 character and 1 character, or you want to interpret that binary as numbers, then use those numbers as ascii codes?
fxn has quit [Quit: zZzZzZ...]
<mblagden_>
if the latter.. I have no idea how you seinsibly map 18 binary digits to ascii
symm- has joined #ruby
<mblagden_>
a multiple of 8 or multiple of 7 would make a bit more sense
nofxx has joined #ruby
nofxx has quit [Changing host]
nofxx has joined #ruby
lkba has joined #ruby
roxtrongo has joined #ruby
jenrzzz has joined #ruby
fedexo has joined #ruby
jenrzzz has quit [Ping timeout: 250 seconds]
rehat has quit [Remote host closed the connection]
psy_ has quit [Ping timeout: 268 seconds]
platzhirsch has joined #ruby
roxtrongo has quit [Remote host closed the connection]
dgutierrez1287 has joined #ruby
pontiki has joined #ruby
jack_ has joined #ruby
jack_ has quit [Client Quit]
jack_ has joined #ruby
craysiii has quit [Remote host closed the connection]
danieli has joined #ruby
<apt-get>
how do I use the gtk toolkit?
<apt-get>
I get this error: tooltips.rb:48:in `<main>': undefined method `init' for Gtk:Module (NoMethodError)
<shevy>
you'll have lots of examples, all with working code in that directory
karmatr0_ has quit [Read error: No route to host]
<shevy>
in total I think you can find about 500 examples
<apt-get>
shevy: thanks!
<apt-get>
wow
xiii_ has quit [Quit: leaving]
karmatr0_ has joined #ruby
Rurik has joined #ruby
Hrorek has quit [Read error: Connection reset by peer]
karmatr0_ has quit [Read error: Connection reset by peer]
DmitryBochkarev has quit [Quit: This computer has gone to sleep]
<shevy>
here is hello world for gtk2: http://pastie.org/10415303 - it may work if you replace gtk2 with gtk3
karmatr0_ has joined #ruby
<shevy>
but gtk is sorta semi-stable... for instance it does not work for me right now /Programs/Ruby/2.2.3/lib/ruby/site_ruby/2.2.0/glib2/deprecatable.rb:138:in `const_get': uninitialized constant ExtensionMode (NameError)
<shevy>
I mean *gtk3, the ruby-bindings to it
karmatr0n has quit [Ping timeout: 264 seconds]
mleung has quit [Quit: mleung]
roxtrong_ has quit [Remote host closed the connection]
newdan has quit [Quit: Lost terminal]
karmatr0_ has quit [Read error: No route to host]
ebbflowgo has quit [Ping timeout: 244 seconds]
karmatr0n has joined #ruby
karmatr0n has quit [Read error: Connection reset by peer]
<shevy>
hmm
karmatr0n has joined #ruby
<FernandoBasso>
What is the difference between arr = 1, 2, 3 (which I got), arr = *[1, 2, 3] and arr = 1, *[2, 3]. The last two seem to result in just the same thing as the first one.