apeiros_ changed the topic of #ruby to: programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails
kenperkins has joined #ruby
jitesh_shetty has joined #ruby
shaggy2dope has joined #ruby
charlenopires has joined #ruby
<rking>
The Koans are great. If you want a similar thing but for regexes, join #regex, then /msg pork !help
<rking>
I'm working through them now.
<species>
maybe ill make pong first though
<species>
thats always funny
blueadept` has joined #ruby
Synthpixel has joined #ruby
wallerdev has joined #ruby
byronb has joined #ruby
eywu has joined #ruby
jameshyde has joined #ruby
dwon has joined #ruby
booginga has joined #ruby
<Boohbah>
species: i really like the ruby quizzes, but i haven't done the koans yet
mbriggs has joined #ruby
hobbyist has joined #ruby
byronb has joined #ruby
dnyy has joined #ruby
hobbyist has joined #ruby
davidcelis has joined #ruby
Rishi_ has joined #ruby
ninor has joined #ruby
SeanTAllen has joined #ruby
Zolrath has joined #ruby
<voodoofish430>
how can I list out the headers of an http request when using Net::HTTP?
eywu1 has joined #ruby
eywu has joined #ruby
shevy2 has joined #ruby
Hsparks has joined #ruby
iamjarvo has joined #ruby
booginga has quit ["Leaving"]
wmoxam has joined #ruby
<senthil>
voodoofish430: from within Net:HTTP or outside?
* wookiehangover
retreats back into his shame-cave
<senthil>
Boohbah: we need "EnglishLite" language, without all the silly rules from dead languages
phantasm66 has joined #ruby
freeayu has joined #ruby
h4mz1d has joined #ruby
<senthil>
like receive, but receiving
<Boohbah>
senthil: i disagree. rules from dead languages add flavor
<senthil>
Boohbah: confusion if you ask me
Banistergalaxy has joined #ruby
redgetan has joined #ruby
charlenopires has joined #ruby
liluo has joined #ruby
<shadoi>
"force push my package to anl"
<shadoi>
actually just heard those words spoken.
<Spaceghostc2c>
shadoi: Did you "TWHS"?
<shadoi>
didn't have to, everyone cracked up
brngardner has joined #ruby
<Spaceghostc2c>
Awesome.
stringoO has joined #ruby
nvez has joined #ruby
nvez has joined #ruby
adamkittelson has joined #ruby
kvirani has joined #ruby
ZachBeta has joined #ruby
charlenopires has joined #ruby
apok_ has joined #ruby
vjacob has joined #ruby
mattyoho has joined #ruby
Araxia has joined #ruby
Clordio has joined #ruby
Chryson has joined #ruby
nari has joined #ruby
patrick99e99 has joined #ruby
macmartine has joined #ruby
<patrick99e99>
Hi ruby friends.. I am really stuck on an annoying problem.. Basically, I have a gem in a rails app that is ruining my life. It has a method called "setup" in a module which is destroying my I18n stuff during application initialization. I manually went into the gem and wrapped the setup methody body in an ActiveSupport::on_load(:after_initialize) block, and that fixed the problem.. So then I wanted to make my own initia
<species>
ive installed rubygame via gem, and im wondering where to access the samples it comes with
<species>
i guess the first step is determining if they were installed
<patrick99e99>
and so-- I made an initailizer file and did module ActiveAdmin; def self.setup; puts "HELLO!"; end; end; --- and I never see hello...
<senthil>
species: i use pry for that
<species>
if I look at the project structure on github, the samples are in the same dir as the docs; is that useful to know here?
<havenn>
Anyone know of a script that will minify Ruby code? (Just curious.)
Teddy2steper has joined #ruby
kevinbond has joined #ruby
lninyo has joined #ruby
shadoi has joined #ruby
<seanstickle>
havenn: jrubyc
lninyo has quit ["Leaving"]
dbgster has joined #ruby
chico has joined #ruby
maletor has joined #ruby
robdodson has joined #ruby
dagnachewa has joined #ruby
dv310p3r has joined #ruby
hobbyist has joined #ruby
ed_hz_ has joined #ruby
<robdodson>
could someone explain the difference between templates and partials to me..? i just started using Sinatra and I'm not quite sure where one would prefer one over the other. thank you!
stephenjudkins has joined #ruby
<Boohbah>
robdodson: #sinatra might know
Banistertab has joined #ruby
<senthil>
robdodson: are you talking about Rails templates or templates in general
strict9 has joined #ruby
<senthil>
robdodson: partials are just half templates that you can include into other templates
<senthil>
robdodson: say your header/footer, you put that in a partial and require them in other templates, so less duplication
ed_hz_ has joined #ruby
<robdodson>
senthil: ok.. is it impossible to have a header/footer template which would do the same thing?
<strict9>
Hello. Any idea why "@results.each do |r|" prints out results even if there's nothing in the loop at all, just an "end"? @results is an array of hashes
<robdodson>
senthil: like could i require a header template inside an index template? if not then I understand why you would use a partial instead
<senthil>
robdodson: partials are just a special term for templates that you reuse, its the same thing
scientes has joined #ruby
chioque has joined #ruby
<robdodson>
senthil: ok cool thanks that makes sense
Teddy2steper has joined #ruby
robdodson has quit [#ruby]
robdodson has joined #ruby
savage- has joined #ruby
swittenkamp has quit [#ruby]
Banistertab has joined #ruby
robdodson has joined #ruby
robdodson has joined #ruby
blueadept` has joined #ruby
robdodson has quit [#ruby]
robdodson has joined #ruby
baroquebobcat has joined #ruby
codezombie has joined #ruby
robdodson has joined #ruby
robdodson has joined #ruby
robdodson has joined #ruby
freeayu has joined #ruby
josefig has joined #ruby
josefig has joined #ruby
ryan0x2 has joined #ruby
ed_hz_ has joined #ruby
redgetan has quit ["Leaving"]
tommyvyo has joined #ruby
mmokrysz has joined #ruby
seivan has joined #ruby
yoklov has joined #ruby
Bosma has joined #ruby
adeponte has joined #ruby
joaoh82 has joined #ruby
lewis has joined #ruby
lewix has joined #ruby
macmartine has joined #ruby
savage- has joined #ruby
k04n has joined #ruby
beilabs has joined #ruby
libertyprime has joined #ruby
cap10morgan has joined #ruby
abstrusenick has joined #ruby
rohit has joined #ruby
sub_stantial has joined #ruby
recycle has joined #ruby
deobald has joined #ruby
SpitfireWP has joined #ruby
Hsparks has joined #ruby
mdw has joined #ruby
Houdini has joined #ruby
sectionme has joined #ruby
Teddy2steper has joined #ruby
ABK has joined #ruby
rippa has joined #ruby
steg132 has joined #ruby
senthil has joined #ruby
hobbyist has joined #ruby
shaggy2dope has joined #ruby
nikhgupta has joined #ruby
Animawish has joined #ruby
<Animawish>
i've got a program where I open a file (File::open) and later I use gets, but instead of asking for input in terminal, the gets just pulls the first line of the file
<Animawish>
I don't understand why it's doing it or how to fix it
vandemar has joined #ruby
m_3 has joined #ruby
<shadoi>
you probably want $stdin.gets
adamkitt_ has joined #ruby
phipes has joined #ruby
zeroeth has joined #ruby
<Animawish>
thanks shadoi
ben225 has joined #ruby
Animawish has quit [#ruby]
<species>
so im doing the ruby koans and im failing on this test: assert_equal 0, false.object_id
<species>
ive got a seperate file with puts false.object_id and that gives me "0"
lkba has joined #ruby
<species>
as a fixnum
<species>
so how come its failing?
ABK has joined #ruby
deobald has joined #ruby
savage- has joined #ruby
<species>
in fact, puts false.object_id == 0 gives me "true"
<species>
this points to assert_equal doing something stupid
CheeToS has joined #ruby
<species>
lol false alarm I hadn't saved the file >_<
hobbyist has joined #ruby
tommyvyo has joined #ruby
tommyvyo has joined #ruby
artm has joined #ruby
wallerdev has joined #ruby
nikhgupta1 has joined #ruby
MrGando has joined #ruby
ryanf has joined #ruby
kenneth has joined #ruby
gtuckerkellogg has joined #ruby
a_a_g has joined #ruby
<kenneth>
hey, you know when you do `bundle gem` and it creates a directory structure for you, it goes through files if they're already there and offers to overwrite them, diff them, etc
<kenneth>
is that a standard gem i can use in my own project, or should i re-invent the wheel
gokul has joined #ruby
Vert has joined #ruby
abionic has joined #ruby
Asher1 has joined #ruby
dwon_ has joined #ruby
Indian has joined #ruby
lewix has quit ["Leaving..."]
Indian has joined #ruby
nari has joined #ruby
Asher has joined #ruby
<kenneth>
other question, in ruby, if i assign a block to a variable, is it aware of that variable in that scope
<kenneth>
i.e., can i do `test = lambda { |arg| test.call(arg+1) }`, use a lamda recursively
neurotech has joined #ruby
sacarlson has joined #ruby
eldariof has joined #ruby
gtuckerkellogg has joined #ruby
kenichi has joined #ruby
rckts has joined #ruby
sam113101 has joined #ruby
indeterminate has joined #ruby
djdb has joined #ruby
<rippa>
kenneth: yes you can
x0F_ has joined #ruby
jankly has joined #ruby
vectorshelve has joined #ruby
nfluxx has joined #ruby
phantomfakeBNC has joined #ruby
geekygator has joined #ruby
sspiff has joined #ruby
andrewhl has joined #ruby
BrianJ has joined #ruby
kawa_xxx has joined #ruby
Helius has joined #ruby
nfluxx_ has joined #ruby
shruggar has joined #ruby
Clordio has joined #ruby
mistergibson has joined #ruby
senthil has joined #ruby
alem0lars has joined #ruby
<mistergibson>
I'm attempting to work with File and IO modes numerically. to set 'wb' do I ( File::Constants::WRONLY + File::Constants::BINARY ) ? xor? anyone know?
stephenjudkins has joined #ruby
nikhgupta1 has quit [#ruby]
arturaz has joined #ruby
arturaz has joined #ruby
seivan has joined #ruby
liluo has joined #ruby
shtirlic has joined #ruby
zeroeth has joined #ruby
Houdini has joined #ruby
alup_ has joined #ruby
apeiros_ has joined #ruby
io_syl has joined #ruby
Akuma has joined #ruby
stephenjudkins has joined #ruby
c9s has joined #ruby
LMolr has joined #ruby
JohnBat26 has joined #ruby
Helius has joined #ruby
artm has joined #ruby
InBar has joined #ruby
seivan has joined #ruby
neersighted|AFK has joined #ruby
trivol has joined #ruby
davidpk has joined #ruby
vectorshelve has joined #ruby
yxhuvud has joined #ruby
<RubyPanther>
mistergibson: Foo ^ Bar
looopy has joined #ruby
<mistergibson>
RubyPanther: thx :)
<_ack>
I think you need and (|) not xor for that.
johndbritton has joined #ruby
<mistergibson>
oh?
<_ack>
I meant to say or.
<_ack>
mistergibson you are trying to put together those constants right?
ukwiz has joined #ruby
<mistergibson>
yup
d3c has joined #ruby
zeroeth has joined #ruby
<_ack>
well that in C/stdlib file api is done by or'ing them together. So later on can be checked by doing somthing like if (flag & BINARY), if (flag & WRONLY), etc..
<mistergibson>
_ack: ok, I see -- thanks
mrmist_ has joined #ruby
ben225 has joined #ruby
DuoSRX has joined #ruby
ephemerian has joined #ruby
KL-7 has joined #ruby
kawa_xxx has joined #ruby
ben225 has joined #ruby
BiHi has joined #ruby
nemesit has joined #ruby
nemesit|osx has joined #ruby
bhavesh_a_p has joined #ruby
Asher has joined #ruby
timonv has joined #ruby
trivol has joined #ruby
<shevy2>
when will there be ruby 2.0?
<apeiros_>
it came out yesterday. didn't you read the news?
snearch has joined #ruby
roolo has joined #ruby
<shevy2>
:(
trivol has joined #ruby
<RubyPanther>
shevy: yugui already said, next is 1.9.4, and then 2.0. And it will be less change than 1.8->1.9
<RubyPanther>
so probably 6 months or more
<shevy>
aha
<shevy>
okay
maasha has joined #ruby
<maasha>
Hey, do we have a constant for the number of bits in uint64_t ?
<apeiros_>
eh, are you serious?
<apeiros_>
uint64_t says it's 64bit…
<RubyPanther>
That means it can hold a 64 bit number, it doesn't mean it isn't actually bigger though, right?
<maasha>
apeiros_: well, I guess I meant what is the size of unsigned int? that depends on OS.
<maasha>
or CPU
<apeiros_>
maasha: no, if you say uint64_t you explicitly request a 64bit wide integer
<RubyPanther>
Normally you don't care unless you're writing a C extension, and then you can check in C
<maasha>
that is why we have uint64_t, no?
<apeiros_>
and by stating you want it unsigned, you just say that you don't want an initial 1 to mean the number is negative.
<maasha>
RubyPanther: I am fiddling with Inline C.
<apeiros_>
so an uint64_t will always have 64bits. otherwise it is not an uint64_t
BiHi has joined #ruby
<maasha>
apeiros_: right. but does ruby have a constant for the size of int?
<apeiros_>
why would ruby have one? ruby doesn't expose architecture internals…
<apeiros_>
sizeof(int) in C
<Mon_Ouie>
Ruby can deal with arbitrarily large integers transparently
two- has joined #ruby
bier has joined #ruby
<maasha>
apeiros_: I wanted a bitmap encoded as an array of uint64_t, but the easy way is to initialize that as a ruby string - I just need the size of the int for correct padding.
<maasha>
so a mix of Ruby and C using inline ...
<apeiros_>
maasha: you realize that int != uint64_t ?
<maasha>
i need blocks of 64 bits for my bit map.
<maasha>
happens to be unsigned int on my mac.
<apeiros_>
…
<maasha>
not portable, though. on a 32 bit system it will go haywire.
vandemar has joined #ruby
kawa_xxx has joined #ruby
batmanian has joined #ruby
blacktulip has joined #ruby
ABK_ has joined #ruby
emilkarl has joined #ruby
havenn has joined #ruby
scientes has joined #ruby
<mistergibson>
maasha: can you use two uint32 in tandem?
scientes has joined #ruby
<mistergibson>
if it is merely a bitmap basket
d3vic3 has joined #ruby
<mistergibson>
sounds like some hooley you can pull in the .h
ikbenhet has joined #ruby
lessless has joined #ruby
trivol_ has joined #ruby
Brendan_ has joined #ruby
quest88 has joined #ruby
sgronblom has joined #ruby
<sgronblom>
Does it really make sense for every HTTP response status code to be a subclass of HTTPResponse?
<sgronblom>
Why aren't the codes just simple constants?
riginding has joined #ruby
<apeiros_>
it's not the status codes that are subclasses
<apeiros_>
the whole response is
<sgronblom>
That's true. But still?
<apeiros_>
and yes, it makes sense
seivan has joined #ruby
<apeiros_>
enables a couple of possibilities in dealing with the response. also enables to add custom methods for different responses.
<apeiros_>
doesn't mean it's the only meaningful way to deal with those problems.
<sgronblom>
but do the classes take advantage of that?
<apeiros_>
why don't you just open the source code and see?
<sgronblom>
well I'm checking out the docs
Gekz has joined #ruby
Gekz has joined #ruby
Gekz has joined #ruby
Gekz has joined #ruby
<mistergibson>
its seems the philosophy with Ruby is: the source *is* the documentation
<sgronblom>
yeah and even then figuring out what parameter to give to Net::HTTPResponse's constructor is unclear
<sgronblom>
Because whee, lib/net/http.rb is a single file of 2.2kloc with multiple classes
<sgronblom>
Internal use only
<sgronblom>
So how did they expect me to create a response if I am mocking net http?
<vectorshelve>
I have an rspec test case -> https://gist.github.com/2318432 which I recorded using selenium IDE... I added into my Gemfile installed gem rspec rails and selenium-webdriver. When I run rspec from the console a firefox window pops up stays there for a while and exits...the error message I am getting is -> https://gist.github.com/2318427 please help with where am I going wrong.. thanks
<vectorshelve>
The test cases are running properly while I ercorded it in the Selenium IDE and re ran it... I then exported it to rpsec... Now I am having trouble running the test cases from rpsec.. please help me get it right.. thanks
mengu_ has joined #ruby
spasbot has joined #ruby
__main__ has joined #ruby
pkkm has joined #ruby
__main__ has joined #ruby
Spring___ has joined #ruby
<pkkm>
Hello. I need to execute an external program from a Ruby script. I don't need its output. Should I use %x[/path/to/program arg1 arg2], system("/path/to/program arg1 arg2") or system("/path/to/program", "arg1", "arg2")?
<matled>
pkkm: should the output be printed to stdout anyway?
<pkkm>
matled, I don't care, the program I want to call doesn't print anything to stdout.
<matled>
pkkm: I prefer any method that takes the command arguments as separate arguments, like system. if the arguments are static that's not so important but it's very helpful if the arguments are dynamic.
<matled>
pkkm: in this case I'd use system.
<pkkm>
matled, I don't need to escape arguments when using system("/path/to/program", "arg1", ...), right?
<matled>
pkkm: no, the arguments are passed as they are to the program
<pkkm>
matled, OK, thanks for help.
<matled>
pkkm: system("/path/to/program arg1 arg2") is actually system("sh", "-c", "/path/to/program arg1 arg2") and sh will interpret the string. therefore you need to take care of the arguments when passing them as a single string
ddoucette has joined #ruby
CodeFriar has joined #ruby
shell0x_ has joined #ruby
SPYGAME has joined #ruby
looopy has joined #ruby
<sgronblom>
The "joy" of TIMTOWDY :)
kaiwren has joined #ruby
rushed has quit [#ruby]
crazed has joined #ruby
akem has joined #ruby
Jackneill has joined #ruby
<artm>
what's a vim script to auto insert 'end' where appropriate?
ben225 has joined #ruby
zeroeth has joined #ruby
iocor has joined #ruby
aibo has joined #ruby
bwwrd has joined #ruby
<artm>
ah, found it
etehtsea has joined #ruby
sohocoke has joined #ruby
abionic has joined #ruby
liluo has joined #ruby
KL-7 has joined #ruby
ABK has joined #ruby
kaiwren has joined #ruby
ABK_ has joined #ruby
KL-7 has joined #ruby
falena has joined #ruby
<pkkm>
Is there a shortcut for things like 'if my_string == "option1" or my_string == "option2" or my_string == "option1" or my_string == "option4"' ?
<apeiros_>
if options.include?(my_string) then
<rippa>
if [o1,o2,o3,o4].include? my_string
<pkkm>
Thanks
mcwise has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
byronb has joined #ruby
davidcelis has joined #ruby
<Mon_Ouie>
string.start_with? "option" and string[-1].between? "1", "4"
<Mon_Ouie>
Ok, doesn't work actually
Rishi- has joined #ruby
<apeiros_>
my_string =~ /\Aoptions[1-4]\z/
<apeiros_>
my_string =~ /\Aoption[1-4]\z/ # whoopsie, an 's' too much…
LMolr has joined #ruby
orbus5 has joined #ruby
alem0lars has joined #ruby
Rishi_ has joined #ruby
<canton7>
apeiros_, hrm. His passes for 'optionyay1', yours fails
<orbus5>
ah guess I dont need to put it since its a method anyway
<apeiros_>
wrong reason, correct conclusion…
waxjar has joined #ruby
<apeiros_>
correct reason: you don't need to puts there because your display method already puts.
<rippa>
why can't people just gg=G
gokul has joined #ruby
<apeiros_>
reason for nil being printed: display returns nil. so puts disc[1].display --> puts nil --> which prints nil
<orbus5>
newbism?
<apeiros_>
rippa: not everybody uses an OS as editor :-p
<orbus5>
great thanks, I'll clean up the indents
<orbus5>
it works now of course, no nil
<apeiros_>
orbus5: discs.to_i --> discs.size
greenarrow has joined #ruby
<apeiros_>
oh, it seems…
<apeiros_>
where does discs come from?
JohnBat26 has joined #ruby
<orbus5>
apeiros_: coding tower of hanoi for practice
<apeiros_>
orbus5: I meant the variable :)
<apeiros_>
you never assign to it in the pasted code
<orbus5>
its before the class, discs = gets
<apeiros_>
I'd do the to_i there then, once. instead of every iteration.
<apeiros_>
I'd also use Integer(gets) instead of gets.to_i
<apeiros_>
that'll raise if the user enters something that is not an integer
<apeiros_>
Integer(gets, 10) if you want to enable entries like 009 (Integer would consider it to be octal otherwise)
davidpk has joined #ruby
steg132 has joined #ruby
pshah1 has joined #ruby
bawerd has joined #ruby
<pshah1>
hi
<pshah1>
hello
<pshah1>
pls reply hi
pshah1 has joined #ruby
<pshah1>
hiiiiii
<apeiros_>
hi
pshah1 has joined #ruby
<apeiros_>
pshah1: yes, your irc client works…
<pshah1>
hi
<pshah1>
means ur work is irc
nari has joined #ruby
pshah1 has joined #ruby
<apeiros_>
pshah1: stop joining & parting every minute.
rohit has joined #ruby
<pshah1>
y?
<pshah1>
stop joining & parting every minute
pshah1 has joined #ruby
<Afal>
[6~+
strife25 has joined #ruby
fr0gprince_ has joined #ruby
<vectorshelve>
when I start my test cases using rspec command the browser pops up and asks for proxy username and password... I cant type it over the field.. so the test case fails eventually... how can I get out of this issue ?
arussel has joined #ruby
<arussel>
I have a Hash my_hash = {"foo" => "bar"} , and a string "ddd#{foo}", and I would like to output the string as "dddbar". How can I do this ?
<apeiros_>
arussel: use %{foo} instead of #{foo}
<apeiros_>
then you can use String#%: "ddd#%{foo}" % {"foo" => "bar"}
<arussel>
nice, what is the english name for this operation ?
<apeiros_>
oh, seems that wants the keys of the hash to be a symbol too
<rking>
Perl has -mre=debug, which shows its interpretation of your regex as an indented tree. Is there a similar Ruby tool?
<arussel>
apeiros_: no sprintf, I don't know the variable used
<arussel>
apeiros_: nice, thanks.
ofcan has joined #ruby
nanderoo has joined #ruby
<arussel>
apeiros_: works perfect, thanks again.
<apeiros_>
arussel: you asked for the name, I told you the name.
<ofcan>
what is the best ruby cheatsheet/ poster/ reference/ overview? with object hierarchy, common mehtods, all in color, layed out nice and clearly?
alem0lars_ has joined #ruby
<arussel>
apeiros_: I thought you were offering another solution based on printf :-)
<apeiros_>
my brain :-p
<apeiros_>
arussel: String#% *is* sprintf
<apeiros_>
a % [b,c,d] --> sprintf(a, *[b,c,d])
<apeiros_>
a % b --> sprintf(a, b)
lolmaus has joined #ruby
<lolmaus>
Reading the Pickaxe. Got a question. There's a sample method like this: def price_in_cents; Integer(price*100 + 0.5); end
<lolmaus>
"price" is a local variable, it's not defined!
<rking>
lolmaus: That's not in the context of some class that has a "def price"?
<apeiros_>
lolmaus: it can also be a method
<apeiros_>
ruby doesn't require you to add parens to call a method. i.e., foo() and foo are equivalent
<lolmaus>
rking, apeiros_: ah! I thought i should point to it like self.price... But then it would be a class method, not an instance one?
<apeiros_>
(a local variable `foo` however will take precedence over a method `foo` if you just write `foo`)
<apeiros_>
lolmaus: no, self.foo is a longer way of saying foo
<apeiros_>
self.class.foo would call the class method foo
<lolmaus>
apeiros_, so i should use self.foo for method when i have both a method and a local variable with the same name?
<apeiros_>
I prefer foo()
<lolmaus>
Oh
<apeiros_>
note that self.foo will not work with private methods
<lolmaus>
apeiros_, while foo() will?
<apeiros_>
yes
dotemacs has joined #ruby
<lolmaus>
Nice! Thanx for sorting that out
<apeiros_>
private in ruby means "no explicit receiver" (even if that receiver is self, which would be allowed in other languages)
<apeiros_>
lolmaus: also, if you have arguments, that counts as unambiguous too. so `foo = "hi"; foo "bar"` will work.
<lolmaus>
apeiros_, unless i had a "foo=" method? ;)
<apeiros_>
no
<apeiros_>
foo = "bar" will *always* assign to the lvar foo
<lolmaus>
Okay
<apeiros_>
foo= methods must be invoked with a receiver
`brendan has joined #ruby
<lolmaus>
So, foo=("bar") then?
<apeiros_>
no
<apeiros_>
self.foo = "bar"
<Mon_Ouie>
No, self.foo = "bar", which works even if foo= is private
<lolmaus>
OMFG
<apeiros_>
Mon_Ouie: wha? they special cased that?
<lolmaus>
Now i'm confused
<apeiros_>
great…
<Mon_Ouie>
Yes
<apeiros_>
lolmaus: understandable…
<apeiros_>
that's stupid IMO. should make that the same for all methods.
<lolmaus>
So self.foo is also valid for private?
<Mon_Ouie>
No, that's only for setters= methods
<lolmaus>
=-O
<Mon_Ouie>
Because there's no way to call them without an explicit receiver
<rippa>
send
<lolmaus>
Why is `foo=("bar")` invalid?
<Mon_Ouie>
That's explicit
<rippa>
at least it's not special case
<Mon_Ouie>
foo = ("bar") is valid, but it's different
<mistergibson>
lolmaus: for a private method, simply call the method with no receiver
<Mon_Ouie>
It sets the local variable foo to "bar"
<mistergibson>
as if it were a keyword of the language
<lolmaus>
mistergibson, we've been discussing a case with a local variable with the same name as the method. The variable would prevent you from calling the method implicitly.
<rking>
Wait, I am thinking foo=("bar") is allowed, same as foo = "bar"
_null has joined #ruby
<mistergibson>
lolmaus: oic, ok
_null has joined #ruby
<ofcan>
rking: hello mate :)
<rking>
Howdy. =)
<lolmaus>
Mon_Ouie, so why can't i use `foo=("bar")` to call a private method?
<rking>
ofcan: Did F10 work?
<ofcan>
rking: will test your silly printing yellow code now :)
<rking>
=P
_null has joined #ruby
_null has joined #ruby
_null has joined #ruby
<rippa>
lolmaus: because it assigns to a local var
d3c has joined #ruby
_null has joined #ruby
<lolmaus>
rippa, oh... simple assignment is a method itself >_<
<apeiros_>
no
_null has joined #ruby
<apeiros_>
assigning to variables is not a method.
<lolmaus>
Is it equal to `foo.=("bar")`?
<apeiros_>
no
<rippa>
no
<rippa>
assignment is hardcoded
_null has joined #ruby
Foxandxss has joined #ruby
<lolmaus>
rippa, hardcoded with parenthesis too?
<rippa>
yes
_null has joined #ruby
jbw has joined #ruby
<lolmaus>
rippa, so it kinda imitates a method?
<rippa>
foo= is always an assignment
_null has joined #ruby
<rippa>
foo.bar= is a mthod call
_null has joined #ruby
<LMolr>
what about hsh[key] ||= value ? I am trying to figure out how it works.
_null has joined #ruby
SoKoot has joined #ruby
_null has joined #ruby
<lolmaus>
rippa, but i can create a method with a name "=", right?
iamjarvo has joined #ruby
_null has joined #ruby
<rippa>
no
_null has joined #ruby
Squarepy has joined #ruby
_null has joined #ruby
Squarepy has joined #ruby
_null has joined #ruby
SoKoot has joined #ruby
<rippa>
funny
<SoKoot>
hi
_null has joined #ruby
<rippa>
def d=; end; self.d=() # error
<rippa>
ArgumentError: wrong number of arguments (1 for 0)
<apeiros_>
actually, you can
_null has joined #ruby
<lolmaus>
I'm so confused :(
<apeiros_>
o = Object.new; o.define_singleton_method := do "weee!" end; o.send(:'=') # => "weee!"
<apeiros_>
you just will never be able to call it without send.
<rippa>
o = Object.new; o.define_singleton_method :'=' do "weee!" end; o.send(:'=') # => "weee!"
<rippa>
works
_null has joined #ruby
FeLove has joined #ruby
_null has joined #ruby
gokulnath has joined #ruby
<apeiros_>
rippa, yeah, copied the wrong line
linduxed has joined #ruby
fr0gprince_mac has joined #ruby
delinquentme has joined #ruby
kaiwren has joined #ruby
gokul has joined #ruby
<delinquentme>
im looking for an example list of applications where recursion functions happen to be exceedingly more effective than comparison non-recursive algos
<Mon_Ouie>
You can always rewrite the recursive program iteratively by using an array or something similar instead of using the call stack
mattyoho has joined #ruby
<rking>
delinquentme: I default to recursion when I have to walk a tree of data. In my opinion it comes out simpler than trying to manually keep track of the stack.
<delinquentme>
rking, wise.
CodeFriar has joined #ruby
Natch| has joined #ruby
sbanwart has joined #ruby
tommyvyo has joined #ruby
<apeiros_>
walking directories, parsing (not all grammars), searching/printing hierarchical data
davidd___ has joined #ruby
<lessless>
somebody have yesterdays talks log? :)
<delinquentme>
rking, you want me to tweet that at you:D
<rking>
delinquentme: I don't want the FBI knowing I like to program.
<delinquentme>
HA awesome
<rking>
Hehe
<delinquentme>
i can claim that as my own!
tommyvyo has joined #ruby
linoj has joined #ruby
<arussel>
how can I say I want to use File from io and not from another module ?
hobbyist has joined #ruby
<apeiros_>
::File
<rking>
Is there maybe a gem that will cause Ruby to display the internal regex parse? I'm trying to find a ruby equivalent of perl -mre=debug
<apeiros_>
rking: you can recompile ruby with onigiruma debug flags
geekbri has joined #ruby
<rking>
Though seeing the regex parse would only get me half-way to the functionality -f pmre=debug, it also shows the execution of the matching/failing
<apeiros_>
that article might be of interest to you
<rking>
tommyvyo: Heh, actually. I'm working on a vim port of rubular.com So far it's coming along really well, but I'm trying to add a \d command for when you get stuck.
<tommyvyo>
oyyyy!
<rking>
apeiros_: Oh, excellent. I don't think I'll be able to solve the immediate problem with this, but it's still something I want to know about.
silverhand has joined #ruby
<silverhand>
What's the best way to get "ModelName" into "model_name"? I've been trying with gsub for half an hour and I can't get it without having to reverse and chop and reverse again to remove a leading underscore.
<silverhand>
canton7: Thanks! It seems there is already a function built into Rails. :)
<ofcan>
rking: f10 doesn't work :)
<rking>
ofcan: Change the "!chrome --print" to "!echo chrome --print" and tell me what it says. In #vim
dql has joined #ruby
<rking>
ofcan: And this is no time for :), this is time for :|
zeroeth has joined #ruby
<silverhand>
How can I create a new method object, and pass it arguments?
<ofcan>
rking: i have this, and it does nothing... :map <f10>:TOhtml<cr>:%/#ffff00/#aaaa00/g<cr>:w<cr>:!echo chrome --print %<cr>
<rking>
ofcan: You're missing the space after <f10>, and #vim
Mohan has joined #ruby
* rking
covers the eyes of the poor TextMate users.
<ofcan>
rking: ah, ok, switching to #vim
wroathe has joined #ruby
wmoxam has joined #ruby
<rking>
OK guys, I'm doing a small exercise to get better at exploring implementations, stemming from the discussion about RoR's "underscore". I am in pry, and I did 'gem "rails"' ...but now I can't cd to ActiveSupport
<rking>
How do I get the ActiveSupport to be loaded?
<wroathe>
require 'rubygems'
<wroathe>
require 'activesupport'
<rking>
I tried that, but: LoadError: cannot load such file -- activesupport
<rking>
It behaves the same from irb and also directly to ruby.
<wroathe>
require 'active_support'
<rking>
Also, I don't have to say require 'rubygems'... I can do gem 'rails' right away. How come?
ryanlabouve has joined #ruby
fmcgeough has joined #ruby
<rking>
wroathe: Oh, duh. Thanks. =) I should have run .underscore on it! =D
<wroathe>
I didn't actually check before I typed those :P
<wroathe>
You forced me to not be lazy.
mrwalker has joined #ruby
<rking>
Do you happen to know the answer to the "not having to do require 'rubygems'" thing?
CannedCorn has joined #ruby
<rking>
BTW: Run pry then type "get-naked". Weird.
jankly_ has joined #ruby
<apeiros_>
lol?
<apeiros_>
but taking off the clothes of a pretty girl is pretty much the definition of "having a good time" :D
<matti>
Um.
<matti>
Or killing space aliens in Crysis 2
bbttxu_ has joined #ruby
<apeiros_>
or sending masses of zerg into their certain death :D
<matti>
Yes!
<matti>
Zerg Rush \o/
<canton7>
pry/lib/pry/default_commands/easter_eggs.rb for more
<rking>
If you want to ruin the surprises I found the rest in .,,/pry-0.9.8.4/lib/pry/default_commands/easter_eggs.rb
* rking
looks at canton.
<canton7>
win! :)
<rking>
lose. =(
* apeiros_
declares canton7 the winner
<apeiros_>
you won you one internet! congratulations!
<canton7>
and there was much rejoicing
<apeiros_>
you won yourself?
<apeiros_>
meh, I really have to take the advanced or proficiency :-/
* canton7
is one internet
<apeiros_>
s/is/has/
* canton7
won one internet... and won himself :P
<apeiros_>
-.-
* apeiros_
turns off the internet
<rking>
NOO!!
emmanuelux has joined #ruby
* rking
hopes you an read this message, still. Please do not turn off the internet.
<apeiros_>
I already turned it off.
<apeiros_>
the internet is that blue thingy that looks a bit like an 'e', right?
<apeiros_>
damit, why is it not enough that I reinvent other's wheels? why do I have to reinvent my own ones too? >:-(
<apeiros_>
others'
riginding has quit [#ruby]
tk___ has joined #ruby
<canton7>
NIHAN
<canton7>
(not invented here and now)
<apeiros_>
NRR - not recently reinvented
<rking>
NIQE - Not Invented Quite Enough
<apeiros_>
oooh, nice
* apeiros_
goes back and reinvents a bit
<Spaceghostc2c>
NIL - Not Invented Lethargically
netrealm has joined #ruby
strife25 has joined #ruby
<matti>
We should have
<matti>
NFW
<matti>
foo == nfw
<matti>
NFW -- No F* Way
CannedCo_ has joined #ruby
<Spaceghostc2c>
FUCK - Further Understanding Convinces the Knowledgeable
headius has joined #ruby
<matti>
Spaceghostc2c: Wooo...
* matti
takes a note.
<matti>
Spaceghostc2c: Profound!
qos has joined #ruby
<rking>
NoMethodError: undefined method `convince' for #<Knowledge:0x2342234>
<apeiros_>
try .stubborn?, if it returns true, just run .convince until .convinced?
<matti>
Haha
<matti>
apeiros_: +1
actwitty_ has joined #ruby
<actwitty_>
thanks to rails for bringing up www.actwitty.com - the complete you !!! I am live for invites to private beta!
<Spaceghostc2c>
actwitty_: Cool! And nice domain.
<apeiros_>
actwitty_: so basically you enable normal users to know what dataminers know about us already? :)
silverhand has joined #ruby
yoklov has joined #ruby
alek_b has joined #ruby
steg132 has joined #ruby
phantasm66 has joined #ruby
jgarvey has joined #ruby
asteve_ has joined #ruby
d3c has joined #ruby
<shevy>
dataminers know that swiss like chocolate
<asteve_>
me still no understand self
<Spaceghostc2c>
asteve_: Self is the current object in scope.
<asteve_>
why would I create a method with self.?
<matti>
asteve_: Then, join #psychology.
<Spaceghostc2c>
matti: Oh clevar.
<matti>
asteve_: Then will help you with understanding oneself ;]
<Spaceghostc2c>
asteve_: Get the metaprogramming ruby book.
<Spaceghostc2c>
That'll explain why.
<shevy>
asteve_ you create a class method that way
<matti>
Spaceghostc2c: Sorry, could not resist myself.
<Spaceghostc2c>
Especially since ##psychology wouldn't help anyone.
<Spaceghostc2c>
asteve_: That's the one!
schaerli has joined #ruby
<Spaceghostc2c>
Worth every penny
imsplitbit has joined #ruby
<asteve_>
shevy: what is the benefit of a class method?
<shevy>
asteve_ you can use it without having to type .new
<actwitty_>
Spaceghostc2c: thanks!!
<Spaceghostc2c>
asteve_: Something you'll learn in the Metprogramming ruby book!
<Spaceghostc2c>
actwitty_: No wowries. :D
<shevy>
asteve_ rails uses that a lot
<asteve_>
shevy: saved memory or something?
<Spaceghostc2c>
Nope.
<shevy>
asteve_ who said that?
<asteve_>
why not typed .new then?
<asteve_>
type*
<shevy>
because you dont need to instantiate an object for it
<Spaceghostc2c>
You should invest in yourself by going and reading some documentation and books!
<shevy>
but I wonder
<shevy>
"saved memory" ... from where are you coming with this?!?!
<Spaceghostc2c>
shevy: Because you have the object already!
<Spaceghostc2c>
The class is an object!
<shevy>
this is not "Lightning speed C." This is ruby
<asteve_>
shevy: if you don't need to instantiate an object you've saved memory
<matti>
Spaceghostc2c: So, if you want peace with self and understand self. Does this fall under what Freud was teaching? ;]
<shevy>
..
<shevy>
please asteve_ go and use C
<Spaceghostc2c>
matti: I try to not.
<shevy>
you will save 1000% memory that way
<apeiros_>
asteve_: an example for class methods: Date.civil(year, month, day), Date.ordinal(year, day_of_year), Date.commercial(year, week, day_of_week)
<shevy>
think of all the trees you save that way asteve_
<shevy>
and children
<shevy>
will anyone think of the children?!
<apeiros_>
asteve_: all of these will invoke Date.new at one point, but they'll do the conversion of the values for you to pass the correct values to Date.new
<rking>
ofcan and I were talking about ways to explore the builtin classes. I like to use "ri Array\#each", or else drop into irb or pry and try it out.
<rking>
I think there's a way to make pry show more about the builtins.
<apeiros_>
in pry: `? Array#each`
<rking>
Oh, cool.
<apeiros_>
`$ Array#each` if you want the source-code
<ofcan>
yea, I'm new and would find it very useful to explore ruby object hierarchy
<apeiros_>
needs an additional installation iirc
<rking>
pry is my new <3. It can do show-method Array#each and show rb_ary_each().
<rking>
oh, $. Even better.
<apeiros_>
$ == show-method
<rking>
apeiros_ is my new <3, too.
* apeiros_
is either people's <3 or ..I..
<gogiel>
rking: gay
<rking>
gogiel is my super<3.
<ofcan>
pry... oh god, another thing to pick up on :)
* apeiros_
kick gogiel using that as derogatory is not tolerated
gogiel was kicked from #ruby by apeiros_ [using that as derogatory is not tolerated]
* apeiros_
fail
<rking>
ofcan: Definitely worth it. It's powerful.
gogiel has joined #ruby
<ofcan>
ive begun to learn programming 2 months ago... now battling with linux, ruby, rails, vim... what the hell, who's counting... pry learning it is :)
<gogiel>
lol. political correctness ftw
<apeiros_>
gogiel: nothing to do with political correctness.
<rking>
apeiros_: OK, I give up. What is a ..I..?
<apeiros_>
rking: think of a hand, 5 fingers in a specific gesture…
schaerli has joined #ruby
<rking>
ofcan: I am in a similar situation -- I've been away from programming for 5-6 years and am now getting back into it seriously.. the amount of new stuff is overwhelming (but exhilarating)
<rking>
apeiros_: I see.
ABK_ has joined #ruby
<rking>
Hrm... now I wonder how you follow the C calls around in pry. rb_ary_each() is short, and makes me want to read rb_yield()
<shevy>
ofcan the object model is quite simple
<shevy>
basically the core of things is class Object
<rking>
But $ rb_yield doesn't work.
kevinbond has joined #ruby
<rking>
I guess vim -t rb_yield. =)
jlebrech has joined #ruby
<ofcan>
any extra clarification on how classes, modules, objects interact, and how various variables and methods work withing them is more than welcome :)
nacengineer has joined #ruby
<Spaceghostc2c>
rking: The guy who made pry is in here I think.
timonv has joined #ruby
<ofcan>
you don't need to guide me by the hand... just show me the way :)
<VegetableSpoon>
Hi, I'm a lurker and just discovered pry because of you. Thanks :P
<rking>
ofcan: That is a rather broad set of questions.
<apeiros_>
Spaceghostc2c: yes, it's banisterfiend
<shevy>
ofcan, there really is not that much to understand really, it is not so complicated
<Spaceghostc2c>
apeiros_: I know who it is, I wasn't going to highlight him though, kinda potential help vampirey, isn't it?
zeroeth has joined #ruby
<rking>
VegetableSpoon: Awesome! Hehe.. ofcan and I were talking about this in #vim, and we decided to bring it here for reasons exactly like that.
<shevy>
I think all of ruby class hierarchy can go on one .pdf (one page)
<apeiros_>
Spaceghostc2c: oh, I think banister can deal easily with vampires :)
<Spaceghostc2c>
apeiros_: I was protecting the vampires. :p
<apeiros_>
but yeah, I understand your motivation
<apeiros_>
rofl
luxurymode has joined #ruby
<shevy>
vim users make me sad
<shevy>
why use vim when you have emacs :>
<Spaceghostc2c>
Because I don't need >1million keyboard shortcuts.
gokul has joined #ruby
<ofcan>
loving the graphical visualisation of error hierarchy... anything like that for whole Ruby ? :)
kpshek has joined #ruby
<ofcan>
studying architecture, I've come to love graphical visualisations :)
<rking>
shevy: Fair warning, I am vulnerable to all forms, currencies, and denominations of trollbait.
<shevy>
what bait
<shevy>
vim vs. emacs is unfair
<shevy>
you can't win against an OS
<Spaceghostc2c>
shevy: I hear they're thinking of renaming Emacs to GINABL
<Spaceghostc2c>
GNU Is Not A BootLoader
<shevy>
hmm
<Spaceghostc2c>
:DDD
<rking>
shevy: Well, that is part of the philosophical difference, yes. The Unix way is small tools that do their job well. So yes, to use vim you need to also use ctags, grep, etc.
<shevy>
that reminds me... I still have to setup grub2 one day... but I am so lazy :(
neurotech has joined #ruby
<shevy>
omg the unix way...
<shevy>
the philosophy that allowed the creation of perl
<shevy>
because it all was an inconsistent and incoherent mess that it could spawn the chaotic language that is perl
<shevy>
my favourite pry tutorial is to ask banister :)
dql has joined #ruby
<shevy>
is that the one by josh?
<Spaceghostc2c>
Lawl.
ABK_ has joined #ruby
<Spaceghostc2c>
His name is Ryan.
<rking>
shevy: Chaos is an ebb and flow. Perl tied together various idioms as a polyglottish thing, but then it birthed Ruby.
<shevy>
hmm then perhaps I mean another screencast
<Spaceghostc2c>
rking: Which made sense of it all.
<shevy>
hmm isnt that the speaker who also spoke about why failure is necessary?
<Spaceghostc2c>
shevy: You mean avdi?
<Spaceghostc2c>
Him and Exceptions.
<rking>
Spaceghostc2c: Yes, that's what I mean. Tools swing toward complexity as new problems are solved, then it swings back to simplicity as those problems become old.
<shevy>
Spaceghostc2c hmm no ... someone who spoke that failure is a good way to learn something
<troulouliou_dev>
apeiros_, force_encoding came with 1.9.2 right ?
fr0gprince_mac has joined #ruby
<heftig>
troulouliou_dev: if you're reading from a file, make sure it's opened in binary mode
<troulouliou_dev>
i think i did not had the problem on 1.9.1 afai remember
<heftig>
then you automatically get strings of encoding BINARY out of it
<any-key>
working with bytes and binary are a pain in 1.8
<heftig>
any-key: no, just working with multiple encodings is
<troulouliou_dev>
heftig, yes it id from a socket and i don't have the problem , only in irb
philips has joined #ruby
<any-key>
string lacks .bytes and each_byte
<any-key>
which made a few tasks practically impossible
<apeiros_>
troulouliou_dev: no idea
<troulouliou_dev>
any-key, "aaa".scan(/./).each
<any-key>
meh
<any-key>
I prefer bytes :P
<apeiros_>
any-key: you know, in 1.8, all strings were just bytes
<apeiros_>
any-key: so that wasn't really missing.
<apeiros_>
what was missing was .chars
<any-key>
yes
<apeiros_>
for unicode, you could emulate that using unpack
<troulouliou_dev>
i shoul dreread the ruby book for 1.9 :)
Indian has joined #ruby
<any-key>
you can do anything with unpack >.>
<any-key>
and pack
<apeiros_>
oh, and scan, right
artOfWar has joined #ruby
<apeiros_>
/./u
sectionme has joined #ruby
<rking>
Mon_Ouie: Thanks to your snippets a bit ago, I now have read enough that I understand Singleton Classes. apeiros_: Thanks to your irbrc, I had some context when I saw eigenclass mentioned. =)
<troulouliou_dev>
apeiros_, i do ,ot need to specify n if it is a binary string readen from a file or socket a in 1.8 right ?
<rking>
I know it's probably a cliche to express excitement over Ruby stuff, here, but it's come so far since I left. I made a mess in pry, and thought, "You know what.. I'll type reset". Sure enough, it worked. GMTA.
<troulouliou_dev>
i mean for regex /blah/n
<apeiros_>
troulouliou_dev: in 1.8, you can't
<apeiros_>
1.8 doesn't have a concept of encodings
<apeiros_>
to it, all strings are just a bytearray
angelGao has joined #ruby
ABK_ has joined #ruby
<troulouliou_dev>
and in 1.9 all are unicode by dafault ?
<apeiros_>
no
<apeiros_>
in 1.9, they're just encoding-aware.
<apeiros_>
and certain operations require the encoding to be valid
timonv has joined #ruby
<apeiros_>
what encoding a string initially gets depends on a couple of things, depending on the source of the string.
<troulouliou_dev>
apeiros_, where do i get the encoding ?
<apeiros_>
str.encoding # not very surprising…
jgrevich has joined #ruby
jgrevich has joined #ruby
KL-7 has joined #ruby
<troulouliou_dev>
apeiros_, pack still encode as Encoding:ASCII-8BIT , anogh for me :)
<troulouliou_dev>
enough for me :)
blueadept` has joined #ruby
<apeiros_>
no, pack with a specific pattern will use binary. not pack in general.
<troulouliou_dev>
apeiros_, thanks you put me on the good way this saved me a lot of time
<apeiros_>
hm… I expected pack("U*") to return a unicode string…
codezombie has joined #ruby
<apeiros_>
ah, makes sense, though… could be packing binary data along with the U part
<apeiros_>
I retract my previous statement then. seems like pack returns a binary encoded string all the time.
<troulouliou_dev>
apeiros_, one last question what reflection method (if so called) can show me encoding , i mean this is not a methods that i can see with "aaa".methods ..
<troulouliou_dev>
i mean "encoding" nested class
<apeiros_>
as said, str.encoding
ABK_ has joined #ruby
<apeiros_>
ah, you want a list of encodings
<apeiros_>
see the docs of Encoding
andrewhl has joined #ruby
<troulouliou_dev>
ni i mean but in general encoding is a nested class , a method ;; ???
<troulouliou_dev>
a variable ?
<apeiros_>
as said, take a look at the docs of the Encoding class
<troulouliou_dev>
shevy, but inside "mystring".encoding -> encoding is a class of type Encoding , but it is a variable right ?
williamcotton has joined #ruby
<troulouliou_dev>
sorry did not coded in ruby for 1 year and forgot some basics
<shevy>
why would it be a variable?
<apeiros_>
.encoding is a method
jconnolly has quit [#ruby]
<apeiros_>
methods return objects
<apeiros_>
objects are instances of a class. .encoding happens to return objects that are instances of the class Encoding
ABK_ has joined #ruby
<troulouliou_dev>
ok saw it with "string".methods.select {|a| a =~ /enc/}
<apeiros_>
the only things that are are variables are the things that you can put on the left side of a =
<troulouliou_dev>
sorry i just missed it in the raw output of "".methods
<troulouliou_dev>
basically remember now :)
<troulouliou_dev>
apeiros_, shevy thanks
juiceman5000 has joined #ruby
ABK_ has joined #ruby
cobragoat has joined #ruby
angelGao has joined #ruby
ABK_ has joined #ruby
joaoh82 has joined #ruby
<Mon_Ouie>
It's a method on String. What do you call a nested class?
<shevy>
troulouliou_dev but the part inside // is just a string that wants to match against any word containing the string "enc"
<Mon_Ouie>
oh, didn't scroll all the way down
<shevy>
I think it would be faster to use a.include? 'enc' rather than use //
<Mon_Ouie>
methods.grep(/enc/)
<rking>
So, how could I get String...something....has_key? :encoding ? Of course I can do String.new.has_key? :encoding, but it seems like there should be a way to list the methods that would be on an instance of the class.
<rking>
Sorry, I meant "I can do String.new.methods.has_key? :encoding"
<Mon_Ouie>
String.method_defined? :encoding
<apeiros_>
and "some string".respond_to?(:encoding)
<Mon_Ouie>
And that #has_key? method isn't defined on arrays
<Mon_Ouie>
There's #include?
<apeiros_>
shevy: include? checks for ==
<rking>
Ugh, I'm being soo sloppy,. Yes, I meant .include?
<apeiros_>
shevy: so include? :enc would not work
<rking>
Mon_Ouie: What about getting them as a list?
<apeiros_>
.methods.include? is significantly slower than .respond_to?
<rking>
apeiros_: But that's checking the instance.
<apeiros_>
rking: so is methods
<apeiros_>
rking: unless you wanted to write instance_methods
<Mon_Ouie>
apeiros_: I think he meant select { |a| a.include? … } instead of select { |a| a =~ … }
<rking>
apeiros_: Right.. but I'm looking for the direct way to go from class -> list of instance methods.
tommyvyo has joined #ruby
<apeiros_>
and then method_defined? is significantly faster than instance_methods.include?
cachoimechi has joined #ruby
<apeiros_>
rking: yes, instance_methods, as stated
<rking>
apeiros_: Yes, that's what I was looking for. =)
<rking>
I wonder why the use of "#" for "String#encoding". It seems a bit odd to use the comment char for it, to me.
<apeiros_>
rking: . is ambivalent, :: is used for class methods
<apeiros_>
what'd you use?
<apeiros_>
# makes it at least clear, that it's not meant to be used in code directly like that.
<rking>
apeiros_: Aha, that is a good advantage of #, yep.
<Mon_Ouie>
I think the convention comes from Smalltalk
<rking>
Oh? Shucks, that means I'm forgetting my Smalltalk.
<apeiros_>
somebody should go and invent hypetalk
<apeiros_>
nobody forgets that
mrsolo has joined #ruby
<apeiros_>
or hipstertalk
<rking>
Mon_Ouie: I think Smalltalk #(...) is like Ruby [...]
<robdodson>
can I ask a very n00b question… why does ruby have so many redundant methods? for instance String#chars or String#each_car. I see it all over the place but I'm not what the reasoning behind it is.
Teddy2steper has joined #ruby
banjara has joined #ruby
<rking>
I'm trying to understand this Hypertalk "the" keyword. It might be a simple optional throwaway thing... I'm not sure yet.
cloke has joined #ruby
SegFaultAX|work has joined #ruby
<apeiros_>
I think it is
<apeiros_>
(optional)
<rking>
robdodson: Well, those two are different. "".chars.each would be like "".each_char
nlc has joined #ruby
galymzhan has joined #ruby
<apeiros_>
rking: each_char and chars are aliases
<rking>
apeiros_: =\ I gross.
galymzhan has quit [#ruby]
<apeiros_>
rking: I the gross?
cwang has joined #ruby
<rking>
apeiros_: Yeah. Why don't we add 1000s of optional keywords
davidcelis has joined #ruby
<apeiros_>
rking: readability
jameshyde has joined #ruby
<rking>
"send the message symbol :encoding to the object string quote 'foo'"
strife25 has joined #ruby
<rking>
Vs. 'foo'.encoding
<robdodson>
rking: chars and each_char seem to produce the same results when I use them.. they look the same in the docs to me
<rking>
robdodson: apeiros_ said it's an alias. I'm not sure why we have both, or even to search around and find the discussion that caused one or the other.
<robdodson>
so, I recognize that they alias the same functionality..my question is why? just to make the code more readable depending on your style?
<rking>
robdodson: Probably not that reason, no.
<apeiros_>
robdodson: I don't know. extensive use of aliases is something I dislike about ruby
<rking>
robdodson: Otherwise we'd have .to_s .s .str .to_string .to_sequence_of_characters_that_i_like etc.
ben225 has joined #ruby
<apeiros_>
the only case for aliasing I find reasonable is for semantically equal special methods
<apeiros_>
e.g. if you alias == and eql?
<Mon_Ouie>
Especially since alias makes a "copy" of the method (changing either of them has no effect on the other method)
<Mon_Ouie>
(except perhaps for recursive methods)
<apeiros_>
Mon_Ouie: I tend to think more of it like assignments to variables
<apeiros_>
i.e. def foo assigns a method, alias foo assigns that method to another name
<apeiros_>
similar as x = "foo"; y = x; x = "bar" does not influence y
<apeiros_>
(it's also probably closer to what actually happens behind the curtain)
mcwise has joined #ruby
apok has joined #ruby
timonv has joined #ruby
x77686d has joined #ruby
juiceman5000 has quit [#ruby]
mmercer has joined #ruby
dbgster has joined #ruby
mmercer has joined #ruby
syamajala has joined #ruby
krz has joined #ruby
ozymandius has joined #ruby
adamkittelson has joined #ruby
RORgasm has joined #ruby
apok has joined #ruby
moshee has joined #ruby
ben225_ has joined #ruby
mmercer has joined #ruby
j3r0m3 has joined #ruby
malcolmva has joined #ruby
rippa has joined #ruby
mmercer has joined #ruby
<mmercer>
hrm
tommyvyo has joined #ruby
stephenjudkins has joined #ruby
species has joined #ruby
geekfactor has joined #ruby
geekfactor has joined #ruby
shadoi has joined #ruby
tewecske has joined #ruby
savage-_ has joined #ruby
brngardner has joined #ruby
MrGando has joined #ruby
natemcguire_ has joined #ruby
x77686d has joined #ruby
lockweel has joined #ruby
artm has joined #ruby
voodoofish430 has joined #ruby
j3r0m3 has joined #ruby
Eldariof59-ru has joined #ruby
<rking>
Mon_Ouie: Ahh yes, Smalltalk #(...) is our [...], but #sym is our :sym.
kenichi has joined #ruby
otters has joined #ruby
headius has joined #ruby
adeponte has joined #ruby
cha1tanya has joined #ruby
tvw has joined #ruby
Nisstyre has joined #ruby
dzhulk has joined #ruby
stkowski has joined #ruby
kenichi has joined #ruby
daniel_hinojosa has joined #ruby
strife25 has joined #ruby
pu22l3r has joined #ruby
tommyvyo has joined #ruby
Eldariof-ru has joined #ruby
Sailias has joined #ruby
berserkr has joined #ruby
RORgasm has joined #ruby
linoj has joined #ruby
arturaz has joined #ruby
jasmim has joined #ruby
jasmim has quit [#ruby]
looopy has joined #ruby
bawerd has joined #ruby
mdw has joined #ruby
hasrb has joined #ruby
mmlug has joined #ruby
<mmlug>
hi
<mmlug>
i need your help..
<mmlug>
how can i generate random integer 10 times
<mmlug>
test = rand(10 ** 10).to_s.rjust(10,'0')
<mmlug>
how can i create this random number in 10 times
Progster has joined #ruby
<shevy>
10.times
<hasrb>
10.times { puts rand(10) }
<Sp4rKy>
:)
<mmlug>
i want to have test = rand(10 ** 10).to_s.rjust(10,'0') 10 times..
<shevy>
then use
<shevy>
10.times
<shevy>
just pass inside the block
<hasrb>
mmlug: do you want an array with 10 integers?
<shevy>
the part between {}
<mmlug>
ya
phantomfakeBNC has joined #ruby
<hasrb>
test = 10.times.collect { rand(10) }
<hasrb>
whatever number is in rand() is the range it will pick from
levity_island has joined #ruby
evilgeenius has joined #ruby
bglusman has joined #ruby
startling has joined #ruby
alem0lars has joined #ruby
<Veejay>
Array.new(N) { rand(M) }
<evilgeenius>
The ActiveRecord methods that I stub are persisting between tests when I use mocha. Is there a way around this?
shadoi1 has joined #ruby
<Veejay>
An array with length N with random numbers in 0..M-1
<mmlug>
when i used like.. test1 = rand(10 ** 10).to_s.rjust(10,'0')
<mmlug>
test = 10.times.collect { rand(test1) }
<mmlug>
puts test
<mmlug>
some number are only 9 digits
nfluxx has joined #ruby
<evilgeenius>
Im using minitest.
<hasrb>
evilgeenius: Are you using any_instance from mocha?
<apeiros_>
mmlug: of course
<hasrb>
evilgeenius: is it in a before block?
<apeiros_>
mmlug: rand(n) gives you random numbers in the range 0...n
<mmlug>
could you point me..?
<apeiros_>
so you could even get a single digit number. read the docs of rand.
<evilgeenius>
hasrb: Im doing this : Product.expects(:find).with(1).returns(product)
<pyreal>
I'm having trouble understanding how to capture multiple strings in a block. Can someone peek at https://gist.github.com/2321801 and tell me where I'm a fail Rubyist?
<mmlug>
still some random number are only 9 digits
Axsuul has joined #ruby
<davidcelis>
pyreal: The block evaluates "foo"
<davidcelis>
pyreal: and then returns "bar"
<evilgeenius>
hasrb: strangely the unstub method is having no effect
<davidcelis>
you probably just want to have the block call puts on both
<davidcelis>
pyreal: ^
<shevy>
pyreal you drop the first part
<shevy>
if you want to return both strings "foo"+"bar"
<davidcelis>
well
<hasrb>
evilgeenius: pastie your test
<davidcelis>
"foo\n" + "bar"
<davidcelis>
or strings.join("\n")
fbernier has joined #ruby
<pyreal>
yeah it works when i 'puts' both strings but i was hoping to be able to return a string and do whatever with it
zakwilson has joined #ruby
<shevy>
who said puts
<davidcelis>
pyreal: Then you want to join whatever strings you have with "\n"
<davidcelis>
shevy: I did because his example was vague and it would achieve what he wants.
<shevy>
ah yeah you did :)
<davidcelis>
pyreal: If you want to return a string and do stuff with it, you need to return the entire string (or all parts in an array or joined) at the end
<pyreal>
davidcelis: kk.. i was trying to reverse engineer RoR capture(&block) style where you can put multiple lines in a block and have them spit back out with modifications
<pyreal>
but I can't figure out what they're doing to extract each separate line
kaneda has joined #ruby
<evilgeenius>
hasrb: the "expects" method call is stopping most of the other tests from working
<hasrb>
evilgeenius: are you referring to how line 28 and 29 are returning the stubbed result?
<hasrb>
evilgeenius: are you expecting it to only be stubbed once?
BrianJ has joined #ruby
<evilgeenius>
hasrb: I only want it to be stubbed for this one test.
chessguy has joined #ruby
<evilgeenius>
hasrb: Not for all my other test cases
headius has joined #ruby
Karmaon has joined #ruby
phantomfakeBNC has joined #ruby
Clordio has joined #ruby
<hasrb>
evilgeenius: and is this test running as expected? Just other tests aren't?
Mohan has joined #ruby
Mohan has joined #ruby
Beakr has joined #ruby
fermion has joined #ruby
<mmlug>
@hasrb could you help me ?
<hasrb>
mmlug: What does the expected end result look like?
ephemerian has joined #ruby
<mmlug>
i want to create random number with 10 digits
<mmlug>
and should be unique
<mmlug>
1000 random numbers
<evilgeenius>
hasrb: All the tests upto that test work fine. The test itself doesn't work, it fails on line 29, and all the tests after it fail with this : "unexpected invocation: Area(id: integer, na.....).find(100)"
jbw has joined #ruby
<hasrb>
evilgeenius: ah, just needed to see that error
<hasrb>
evilgeenius: you have 2 calls to Area.find so that's why it's erroring
<hasrb>
evilgeenius: you have to tell mocha to expect it more than once
mcwise has joined #ruby
x77686d has joined #ruby
Guest30 has joined #ruby
shruggar has joined #ruby
<hasrb>
evilgeenius: it's intentional so that you don't cover up another call to find on accident
<Veejay>
mmlug: SecureRandom.hex(5)
<Veejay>
But that'd be hexadecimal
jbw has joined #ruby
<evilgeenius>
hasrb: I've added the test run log to the end of the gist
<hasrb>
mmlug: to do the unique part you would just have to use the include? method to see if it exists in the array
<evilgeenius>
hasrb: Ok thanks, ill find out how to tell mocha it expect it more than once. It shouldn't affect all the tests after it though should it/
<evilgeenius>
?
<hasrb>
evilgeenius: "- expected exactly once, invoked twice" you have to say .2.times, can't remember the exact format
<hasrb>
evilgeenius: no, since it's just in that specific test block it's only for that one
<mmlug>
hasrb: not sure.
hSATAC has joined #ruby
<Veejay>
.times(2)
<Veejay>
I think
RangerMauve has joined #ruby
jtoft has joined #ruby
<hasrb>
Veejay: thanks
<Veejay>
Which I think is horrible syntax really
<Veejay>
But yeah
<hasrb>
mmlug: read up on the Ruby rdoc, specifically rand(), include? and enumerables
hobbyist has joined #ruby
<RangerMauve>
Hey, wahat would a regex for html tags be? I'm looking to delete all html tags in a string by getting rid of everything that starts with a < and ends with a >
<Veejay>
But you can also enjoy the syntactic sugar of .twice
<jtoft>
Is there a way to stream output of a shell command as it's running, instead of after it's completed?
<hasrb>
RangerMauve: look at the Rails source for strip_tags
datherra has joined #ruby
<RangerMauve>
hasrb: Will do.
<Veejay>
RangerMauve: Why not use a HTML parser to do that?
heftig has joined #ruby
<RangerMauve>
I just want a one line sort of thing that will clean inputs of html for me.
<RangerMauve>
I feel a parser would be overkill
<Veejay>
You won't be able to do taht
<Veejay>
that
<Veejay>
HTML and regexes, sounds like a nightmare
<hasrb>
RangerMauve: yeah, that's not a good idea for inputs
<Veejay>
But I guess you'll see for yourself
<RangerMauve>
Ruh roh
<hasrb>
RangerMauve: also look at the sanitize helper within rails
<RangerMauve>
The thing is though, I'm not using rails. =P
<ezkl>
deception_: It is pretty straight forward. `sudo apt-get install xvfb` then `man xvfb-run`
Guest30 has joined #ruby
heftig has joined #ruby
<evilgeenius>
hasrb: No matter what I do the stubs by mocha are carrying through to the rest of the tests..
<hasrb>
evilgeenius: by carrying through do you mean that it's giving the error of unexpected invocation?
<evilgeenius>
hasrb: yes
<ZenoArrow>
Hi all, trying to make sense of the following code http://pastie.org/3740647 What I don't understand is why the dup method is necessary before capitalising the first letter, why is a duplicate object necessary?
<evilgeenius>
hasrb: so the test is passing now, but the remaining tests all show that error
<evilgeenius>
ZenoArrow: You can just do this : "hello".capitalize
davidpk has joined #ruby
deception_ has quit [#ruby]
<evilgeenius>
ZenoArrow: it's not necessary.
<ZenoArrow>
evilgeenius, thanks for the tip but the code I'm trying to understand isn't mine, apparently it's from the Ruby Cookbook. I'm trying to understand the author's thoughts, as it seems like an unnecessary step to me too.
<evilgeenius>
ZenoArrow: Using dup will ensure that the original object isn't modified, only a copy
<ZenoArrow>
Sure, but you can't access the original anymore if you assign it the same variable name.
daniel_hinojosa1 has joined #ruby
zakwilson has joined #ruby
<evilgeenius>
ZenoArrow: Whoever uses the class will have the original object
<ZenoArrow>
I don't understand, could you elaborate?
Ali1331 has joined #ruby
<matled>
ZenoArrow: the original is the one passed to the method
<Ali1331>
image_tag should take care of the dev/prod difference
blischalk has joined #ruby
<ZenoArrow>
matled, thank you for the pastie, but I'm still confused. Let me put it like this, http://pastie.org/3740730 Is there a scope where x.object_id will return the original value?
<matled>
ZenoArrow: no, the object should have no reference anymore
dbgster has joined #ruby
KL-7 has joined #ruby
<matled>
ZenoArrow: in your original pastie the caller of #first= may still hold a reference to the string after calling the method (i.e. is not using .first= "foo" but .first = var)
<ZenoArrow>
Right, so why is this necessary at all: first = first.dup
<ZenoArrow>
first[0] = first[0].chr.capitalize
<ZenoArrow>
@first = first
<matled>
so the caller's object may be changed by calling the #first= method
Karmaon has joined #ruby
madhatter has joined #ruby
<ZenoArrow>
matled, in the original pastie, how does the code know which of the 'first' values it should be using?
<ZenoArrow>
Seems to me, the reference to the object is replaced.
<matled>
ZenoArrow: try this with and without line 9: firstname = "foo"; name = Name.new; Name.first = firstname; puts firstname
<matled>
err, s/Name.first/name.first/
<matled>
oh, I didn't look at the constructur, but you should be able to modify the code to work :)
<ZenoArrow>
matled, okay trying that out now. Ali1331, it's hard to describe emacs, but you can think of it as a text editor with lots and lots and lots of extra functionality.
<davidcelis>
its like vim, only worse
<ZenoArrow>
...and better.
<davidcelis>
ha ha ha
<davidcelis>
ಠ_ಠ
<ZenoArrow>
;-)
andrewhl has joined #ruby
scientes has joined #ruby
<shevy>
emacs is a pretty good OS
<ZenoArrow>
emacs is ridiculously feature packed, I've tried it out a number of times, got my eye on a few projects that take Emacs and give it more sensible keybindings. The 'language' of editing text in vi is something I prefer, but emacs is better for everything else (from what I've seen). Of course with viper mode and similar you can have the best of both. :-)
fmcgeough_ has joined #ruby
Floydzy has joined #ruby
<ZenoArrow>
matled, okay I've tried making your changes. See new pastie: http://pastie.org/3740848 . Is this what you wanted me to try?
<matled>
ZenoArrow: exactly, try this with and without line 9
downtown has joined #ruby
<ZenoArrow>
Okay, thanks. Tried without line 9, the output is exactly the same, just the string 'Foo'.
<matled>
ZenoArrow: for me it is "foo" with line 9 and "Foo" without line 9
<ZenoArrow>
Ah, actually you're right, I wasn't paying attention!
<ZenoArrow>
Will take a look into what's happening now.
<shevy>
ZenoArrow hmm you wrote "editing text in vi" why did you write vi? :)
n8ji has joined #ruby
timonv has joined #ruby
<ZenoArrow>
shevy, vi is what vim is based on. The basic structure of editing text is similar in both. This is the best introduction to vi I've ever read, if you are unaware of vi then I highly recommend it: http://stackoverflow.com/a/1220118
downtown has quit [""baby don't hurt me, no more""]
<shevy>
I dunno. I used vim and only vim and never cared about vi. Though that was years ago already, I think both emacs and vim are way too complicated
Floydzy has joined #ruby
<ZenoArrow>
shevy, please read the post I linked you to, then you might see the benefits of vi. :-)
<frontendloader>
is there a way to repeat the last X lines in pry?
Cache_Money has joined #ruby
<shevy>
ZenoArrow a million commands to learn for your brain. I'll take the shortcut into a neuronal brain interface instead
<ZenoArrow>
shevy, the point that the post made was that if you understand the language behind vi then the commands are easier to pick up. That's the secret to getting good at using vi.
<shevy>
that is true, one has to think inside the vim in order to use it
zeroeth has joined #ruby
yoklov has joined #ruby
bglusman has joined #ruby
fbernier has joined #ruby
<ZenoArrow>
It's all about efficient text editing, once you get the basics down then you should become more efficient at editing text. If you don't care about editing text efficiently, then vi(m) and emacs aren't for you.
<shevy>
indeed, because all the other editors suck.
<ZenoArrow>
shevy, I wouldn't say that. There are other editors that are good, but in terms of efficiency it's hard to top vim and emacs. From what I've seen, emacs can get more done with less keystrokes compared to vim, look at this: http://www.youtube.com/watch?v=ePIHUfFz8-c
dfamorato has joined #ruby
<shevy>
yeah I dunno
<shevy>
emacs vs. vim, the eternal war
<frontendloader>
golfing is fun, but not a great way to compare the two
<ZenoArrow>
What's that got to do with anything, just pick the tool that suits you best.
<frontendloader>
perl will golf ruby around the block
<ZenoArrow>
frontendloader, I gave it as an example of efficiency, which is what vimgolf is all about.
<Mon_Ouie>
ZenoArrow: Except you kind of have to think 5 minutes before figuring out what commands to use to do that kind of thing
<shevy>
ZenoArrow, I do. I proudly use other editors than vim and emacs.
<shevy>
The efficiency you get by ... spending 100 hours of learning?
<ZenoArrow>
Mon_Ouie, not necessarily, in the example I gave it's a macro, as long as you can think recursively then it's easy to define
<frontendloader>
I don't get much use out of macros except when golfing
<ZenoArrow>
shevy, you don't need to put in that many hours before you see the benefits.
<shevy>
I am fine with the basic keybindings of vim.
<frontendloader>
90% of my vim usage is go here, delete X between Y and Z, type something new
<shevy>
5dd always was fun to do
<shevy>
my gripe was that there was a perpetual learning curve for marginal gains
svg_ has joined #ruby
<frontendloader>
and autoindent spam
<ZenoArrow>
frontendloader, it's all up to personal preferences, I'm not saying you have to use macros if you don't want to.
BrianE|mobile has joined #ruby
<svg_>
how match the string to other string?
<shevy>
Ultimately the real block while programming is not the "efficiency" but the thinking power of your brain.
<shevy>
I understand canton7, but I don't understand svg_
<svg_>
this code put : ["a", "b", "ab"]
<svg_>
but I must get ["ab","b","a"]
ozymandius has joined #ruby
<canton7>
my code outputs ["ab", "b", "a"]
<canton7>
although there's nothing stopping it outputting ["ab", "a", "b"] i guess
<shevy>
svg_, your problem is solved then
monokrome has joined #ruby
<canton7>
shevy, I figured out the problem by looking for patterns in his example, not by what he was saying :P
<ZenoArrow>
svg_, you said regex is not possible because your array is too big. Is "abba" the text you want to search for, or is this just an example of something you're searching for?
<svg_>
ZenoArrow, example, I have big array and many strings
<shevy>
canton7 LOL
<canton7>
svg_, I doubt you'll get something more efficient for finding substrings than "string".include?("substring"). If you need more speed than that, either you need to be writing a C extension, or using another language altogether
<ZenoArrow>
Okay, I'm starting to see what you're doing now, are you trying to compose a larger string out of smaller substrings?
<svg_>
yes
<ZenoArrow>
Okay, well there are a few considerations you need to make first...
bgupta has joined #ruby
<canton7>
ah, yes I see. I missed that particular pattern :P
Deele has joined #ruby
cloke has joined #ruby
<ZenoArrow>
Let's say you have the string "abbato" and you want to find a substring that matches the first part, let's say you have a choice between "a", "ab" and "abb", which do you choose?
<svg_>
longer
<ZenoArrow>
Okay, so in the ideal case you're looking for an exact match, but if not you'll settle for the closest substring you find, yes?
<svg_>
yes
<ZenoArrow>
Okay, well before we get into the code, let's design it logically...
<ZenoArrow>
If you're looking for an exact match, you should look for strings that have the exact same length as the string you're searching for first.
<svg_>
There has to be the best fit. It may be that the matches in front of the longest matching string cuts the string, etc..
<ZenoArrow>
So in other words, first you're looking for "abbato", then you're "abbat", then you're looking for "abba", etc...
<svg_>
my string have 2 MB ;(
<ZenoArrow>
To do this, it's worth rememebering that you can treat strings like arrays...
<ZenoArrow>
svg, look, you're trying to do an inefficent search then, you should look at ways to break the string down first.
<ZenoArrow>
What exactly is this data you're working with? I'm guessing that it might have something to do with music?
MrGando has joined #ruby
<rking>
OK guys, somebody here knows. I used to have this great program, "same", that was the opposite of diff. It was deadly at finding bits of code that people copy&pasted. Any clues where it lives, now?
aibo has joined #ruby
hobbyist has joined #ruby
<ZenoArrow>
svg_ if you can tell us what the data you're working with contains, then it'll be easier for us to help you.
<ZenoArrow>
rking, so this program just showed you what matched?
<ZenoArrow>
svg_, when I run that code, it seems to give the result you're looking for, as in "acaabac" is matched with ["ac", "aab", "ac"]. What's the problem with the code?
lolsuper_ has joined #ruby
lolsuper_ has joined #ruby
MasterIdler_ has joined #ruby
codezombie has joined #ruby
nif has joined #ruby
bluOxigen has joined #ruby
bluOxigen has joined #ruby
<rking>
http://panoptic.com/rking/tmp/same-example.txt # An example of the kinds of ways to use "same". In this case the code was subtlely changed -- it had been copied and pasted, but the symbol names were changed. So to get the matches I ran a s/\w+/symbol/g filter first.
zeroeth has joined #ruby
<ZenoArrow>
I'm off. All the best.
ZenoArrow has quit [#ruby]
nif has joined #ruby
thone_ has joined #ruby
nif_ has joined #ruby
burgestrand has joined #ruby
nif__ has joined #ruby
y3llow has joined #ruby
s0ber has joined #ruby
andrewhl has joined #ruby
y3llow has joined #ruby
nonotza has joined #ruby
gh has joined #ruby
y3llow has joined #ruby
hobbyist has joined #ruby
strife25 has joined #ruby
BrianE|mobile has joined #ruby
artOfWar has joined #ruby
CannedCorn has joined #ruby
just3ws has quit [#ruby]
williamcotton_ has joined #ruby
ozymandius has joined #ruby
Brainix_ has joined #ruby
Prudhvi has joined #ruby
<Prudhvi>
Hi all, i am new to Ruby. I am trying to fix a small script. However, i am trying to find the location where a certain object is defined. How can i figure it out?. I tried a grep, but nothing was conclusive
<gogiel>
Prudhvi: it can be defined anywhere. you can check where method is defined
<apeiros_>
Prudhvi: an *object*? you'll have to follow the code in reverse
<apeiros_>
there's no way to directly find that
<apeiros_>
or do you mean a method? or a class?
<apeiros_>
if the script is indeed small, you can also paste (on pastie.org or gist.github.com) your code and the exception.
mdw has joined #ruby
tatsuya_o has joined #ruby
BrianE|mobile has joined #ruby
burgestrand1 has joined #ruby
eka has joined #ruby
mattyoho has joined #ruby
babinho has joined #ruby
pastjean has joined #ruby
Vendethiel has joined #ruby
maletor has joined #ruby
rexbutler has joined #ruby
<rexbutler>
Question: Suppose I want to draw to arbitrary coords in terminal (in different colors). Is there a way to do it without rbcurses? rbcurses is huge.
mbriggs has joined #ruby
<apeiros_>
rexbutler: google for ansi escape sequences
<apeiros_>
there's some to place the cursor
<rexbutler>
apeiros_: Yeah, I just need to clear screen and move around.
jcromartie has joined #ruby
tjf has joined #ruby
tjf has quit [#ruby]
helichopter has joined #ruby
helichopter has quit [#ruby]
helichopter has joined #ruby
<Prudhvi>
gogiel: apeiros_ thanks, i found it. It is a method in capistrano lib
niku4i has joined #ruby
artm has joined #ruby
mrwalker has joined #ruby
heftig has joined #ruby
chico has joined #ruby
Foxandxss has joined #ruby
Houdini has joined #ruby
prometheus has joined #ruby
td123 has joined #ruby
BrianE|mobile has joined #ruby
josefig has joined #ruby
josefig has joined #ruby
adamkitt_ has joined #ruby
KL-7 has joined #ruby
ben225 has joined #ruby
cmpf has joined #ruby
artOfWar has joined #ruby
kenneth has joined #ruby
wroathe has joined #ruby
mmokrysz has joined #ruby
mengu_ has joined #ruby
mmokrysz has quit [#ruby]
keymone_ has joined #ruby
wilmoore has joined #ruby
<rking>
I get how to use it, but I really don't understand exactly what the <<'s are saying in things like: class Oof; class << self; def rab; 1 end end end
artm has joined #ruby
cpruitt has joined #ruby
gregorg has joined #ruby
<gogiel>
Prudhvi: i like rubymine. ctrl-click on method and you got it :)
DouglasA has joined #ruby
<rking>
Another example of << that I don't get: o = Object.new; mc = class << m; self end
<Spaceghostc2c>
rking: look up eigenclass.
jtoft has quit [#ruby]
wroathe has joined #ruby
<Spaceghostc2c>
You know, someone wrote a book that explains all this.
<rking>
I see by playing with it that mc == o.singleton_class, but I don't get the syntax.
<rking>
Spaceghostc2c: I'm actually looking up eigenclass stuff at the moment, it's what made me ask about <<.
<Spaceghostc2c>
You'll find it in what google should return. It's cool stuff.
<rking>
OK, I'll persist, then.
<rking>
I could definitely use the leg up of knowing what the LHS and RHS of << mean.
mxweas_ has joined #ruby
k3r0 has joined #ruby
adeponte has joined #ruby
dwon has joined #ruby
silverhand has joined #ruby
josefig has joined #ruby
josefig has joined #ruby
delinquentme has joined #ruby
<delinquentme>
OKeeeee lets talk theory ... I'm writing a scraper for academic journal information. I've got Publishers who have journals. journals which have volumes and issues within those volumes ... how to set this up
<delinquentme>
class PublisherScraper which gets the urls of all the journals that publisher publishes
<delinquentme>
then... do I instantiate a class JournalScraper object from that publisher on getting the journal
<delinquentme>
?
looopy has joined #ruby
KnowTheLedge has joined #ruby
keymone has joined #ruby
CheeToS has joined #ruby
Bauer has joined #ruby
<bounce>
sign up for udacity's "cs101: building a search engine".
rtyler has joined #ruby
<rtyler>
I'm feeling a bit daft here, is there any way I can default bundler to always install the RI docs for gems it installs?
<delinquentme>
Page::Link
<delinquentme>
link here is what?
lewis has joined #ruby
<delinquentme>
when Page::Link then
MrGando has joined #ruby
zeroeth has joined #ruby
RORgasm has joined #ruby
gtuckerkellogg has joined #ruby
Karmaon has joined #ruby
mbriggs has joined #ruby
danielvdotcom has joined #ruby
apok_ has joined #ruby
netrealm has joined #ruby
<shevy>
I believe link is a
<shevy>
hmm
<shevy>
link
<Sou|cutter>
https://gist.github.com/2324019 <-- I have no idea why this segfaults... do rspec and fibers just not play together at all?