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
mmokrysz has joined #ruby
Ryougi_Shiki has joined #ruby
CannedCorn has joined #ruby
mxweas has joined #ruby
cobragoat has joined #ruby
dross has joined #ruby
\13k has joined #ruby
orospakr has joined #ruby
linoj has joined #ruby
briankbuckley has joined #ruby
michaelh has joined #ruby
two- has joined #ruby
td123 has joined #ruby
<sam113101>
I'm writing a chat client in ruby, I've written a serializer and a deserializer, I'd extend them if ruby had supported multiple inheritance
<sam113101>
but that's not the case
<sam113101>
so what should I do? make them static functions?
pdtpatr1ck has joined #ruby
raz has quit ["*fump*"]
mikeric has joined #ruby
Progster has joined #ruby
cloke has joined #ruby
Zolrath has joined #ruby
<heftig>
sam113101: why do you need multiple inheritance?
yellow5 has joined #ruby
Natch| has joined #ruby
Natch| has joined #ruby
exchgr has joined #ruby
<sam113101>
because my chat client needs both the serializer and the deserializer
looopy has joined #ruby
<sam113101>
heftig
<heftig>
so you use composition, not inheritance
<sam113101>
what's composition
<heftig>
seriously?
<sam113101>
yes seriously
<sam113101>
not sure if it's a programming concept or ruby-specific thing
<heftig>
programming
<heftig>
your chat client "has" a serializer and a deserializer instead of "being" one
<heftig>
either by being supplied the (de)serializer on creation, or creating them itself
briankbuckley has joined #ruby
mxweas has joined #ruby
fayimora has joined #ruby
tommyvyo has joined #ruby
<seanstickle>
a cat has ears; a cat is not a subclass of ears
<seanstickle>
composition; inheritance
<sam113101>
so what's the best way to implement this
<seanstickle>
mixins
<epochwolf>
seanstickle: cats also have irresistible cuteness
<seanstickle>
That's more of a Rails feature though
<seanstickle>
cat has_many :cutenesses
mxweas has joined #ruby
<epochwolf>
cat has_two :ears
<seanstickle>
My irascible cat only has one
Ttech has joined #ruby
<epochwolf>
seanstickle: you, sir, have a damaged kitty
<epochwolf>
you'll need to subclass to handle that
<sam113101>
are static methods "bad"?
shevy has joined #ruby
<epochwolf>
OneEaredCat < Cat; has_one :ear
<epochwolf>
sam113101: you mean class methods?
<sam113101>
I don't know, I'm new to ruby
<sam113101>
is it how you call them?
<epochwolf>
sam113101: Cat.genus
<epochwolf>
returns "Felis"
cloke has joined #ruby
<epochwolf>
an instance of a cat would have a species (most likely)
<epochwolf>
unless your class is HouseCat, then it would be a class method.
gtuckerkellogg has joined #ruby
CannedCorn has joined #ruby
newton10471 has joined #ruby
Travis-42 has joined #ruby
<Travis-42>
I have a function that accepts a block: "my_function(arg, &block)" and I want to call another function inside, passing in that block with extra methods: "inner_method_call 'another_arg' do ... with original &block?" I'm not sure I understand how I would do this.
hirotosh_ has joined #ruby
yellow5 has joined #ruby
freeayu has joined #ruby
cobragoat has joined #ruby
<Travis-42>
ah, I could do block.call
briankbuckley has joined #ruby
<sam113101>
how should I require the file web_session.rb
justinmcp has joined #ruby
nerdy_ has joined #ruby
Clordio_ has joined #ruby
michaelh has joined #ruby
mdhopkins has joined #ruby
<sam113101>
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- web_session (LoadError)
<sam113101>
but the file exists… lol
<Asher>
require_relative
locks has quit [#ruby]
<sam113101>
I thought require would look in the current folder too
marknyc has joined #ruby
<Asher>
prior to 1.9 it does, since 1.9.1 ./ was removed from the load_path
<sam113101>
why?
<Asher>
you can make require work by $LOAD_PATH.unshift( './' )
<Asher>
security reasons i believe
kevinbond has joined #ruby
ScottNYC has joined #ruby
kevinbond_ has joined #ruby
mattonrails has joined #ruby
ezkl has joined #ruby
<dzieglersf>
hello
<seanstickle>
alloo
savage- has joined #ruby
mmokrysz has joined #ruby
mmokrysz1 has joined #ruby
keymone has joined #ruby
sacarlson has joined #ruby
bit46 has joined #ruby
mmokrysz has joined #ruby
baroquebobcat has joined #ruby
jwmann has joined #ruby
dbgster has joined #ruby
choffstein has joined #ruby
sharms has joined #ruby
CheeToS has joined #ruby
pdtpatr1ck has quit [#ruby]
looopy has joined #ruby
AndChat- has joined #ruby
nari has joined #ruby
<greyEAX>
im stumped
<greyEAX>
if i wanted to download a file using sockets in ruby how would i do it?
<greyEAX>
i have a server set up which waits for a file
<greyEAX>
but i need to be able to send one
cloke has joined #ruby
<td123>
just read contents and send over socket, on the other end receive all the contents and write to a file no?
gtuckerkellogg has joined #ruby
<td123>
assuming you just want straight tcp
<greyEAX>
so like, readFile = File.open(filename)
shtirlic has joined #ruby
<greyEAX>
sock.write (readFile)
<greyEAX>
?
<shadoi>
greyEAX: open just opens, if you want to read it use File.read
<greyEAX>
thx
sharms has joined #ruby
sharms has joined #ruby
nu7hatch has quit [#ruby]
radic_ has joined #ruby
mxweas_ has joined #ruby
ghostlines has joined #ruby
moeSeth has joined #ruby
andrewhl has joined #ruby
philcrissman has joined #ruby
pdtpatr1ck has joined #ruby
dv310p3r has joined #ruby
brianpWins has joined #ruby
dubellz has joined #ruby
ghanima has joined #ruby
mbriggs has joined #ruby
arvidkahl has joined #ruby
abstrusenick has joined #ruby
cloke has joined #ruby
iocor has joined #ruby
brngardner has joined #ruby
davidcelis has joined #ruby
18VAADJUE has joined #ruby
65MAAGJOF has joined #ruby
chimkan_ has joined #ruby
lauwar has quit [#ruby]
arvidkahl has joined #ruby
jgrevich_ has joined #ruby
jgrevich_ has joined #ruby
sdwrage has joined #ruby
pygmalion has quit [#ruby]
dbruns has joined #ruby
<dbruns>
is there an easy way in ruby to determine the date of "This week's Monday"
CannedCorn has joined #ruby
cha1tanya has joined #ruby
<CombatWombat>
Activesupport has what you need, afaik.
sako has joined #ruby
freeayu has joined #ruby
rohit has joined #ruby
cameron_ has joined #ruby
a_a_g has joined #ruby
h4mz1d has joined #ruby
arvidkahl has joined #ruby
adeponte has joined #ruby
freeayu_ has joined #ruby
rippa has joined #ruby
hemanth has joined #ruby
dql has joined #ruby
savage- has joined #ruby
dubellz has joined #ruby
dankest has joined #ruby
dankest has quit [#ruby]
a_a_g has joined #ruby
looopy has joined #ruby
h4mz1d has joined #ruby
arvidkahl has joined #ruby
Animawish has joined #ruby
lkba has joined #ruby
Animawish has quit [#ruby]
pdtpatr1ck has joined #ruby
banjara has joined #ruby
a_a_g has joined #ruby
kremiak has joined #ruby
stevenrockarts has joined #ruby
mxweas_ has joined #ruby
stevenrockarts has quit [#ruby]
artm has joined #ruby
dfibre has joined #ruby
kovax12 has joined #ruby
wefawa has joined #ruby
arvidkahl has joined #ruby
yxhuvud has joined #ruby
jgrevich has joined #ruby
jgrevich has joined #ruby
CannedCorn has joined #ruby
sdeobald has joined #ruby
chimkan_ has quit [#ruby]
mikeric has joined #ruby
bluOxigen has joined #ruby
arturaz has joined #ruby
mxweas_ has joined #ruby
Morkel has joined #ruby
sdwrage has joined #ruby
cha1tanya has joined #ruby
yoklov has joined #ruby
teD_thE_PoTHead has joined #ruby
teD_thE_PoTHead has quit [#ruby]
aknewhope has joined #ruby
M- has joined #ruby
CheeToS has joined #ruby
ghosTM55 has joined #ruby
Houdini has joined #ruby
asuka_ has joined #ruby
xxtjaxx has quit [#ruby]
dql has joined #ruby
<rushed>
is there a method of hash creation that allows for both initial values & a default block?
CryptoSec has joined #ruby
srji has joined #ruby
arturas_ has joined #ruby
gtuckerkellogg has joined #ruby
setient has joined #ruby
x0F_ has joined #ruby
djdb has joined #ruby
tewecske has joined #ruby
sako has joined #ruby
arvidkahl has joined #ruby
rohit has joined #ruby
adeponte has joined #ruby
d3c has joined #ruby
scalebyte has joined #ruby
prometheus has joined #ruby
bjensen has joined #ruby
sspiff has joined #ruby
sspiff has joined #ruby
hemanth has joined #ruby
<hemanth>
watir-webdriver hackers here?
GoBin has joined #ruby
twinturbo has joined #ruby
paulmillar has joined #ruby
paulmillar has quit [#ruby]
LMolr has joined #ruby
CryptoSec has quit [#ruby]
schovi has joined #ruby
<sacarlson>
hemanth: I havn't used watir in some time and what I was using was firewatir in ubuntu
<sacarlson>
hemanth: it involved mostly setting up automated trades on brokers that had no API interfaces
thomasfedb has joined #ruby
Tick-Tock has joined #ruby
<hemanth>
sacarlson, hmm... i'm porting from watir to watir-webdriver
<sacarlson>
hemanth: oh not sure what the differences are, these examples may have no value then
<hemanth>
yup ^_^
<sacarlson>
hemanth: however what is your general fuctions?
grafthez has joined #ruby
<hemanth>
sacarlson, hell lot! there are about 1600 scripts, so almost all of them are used :/
<grafthez>
what gems, projects etc can you advice for newbie to take a look at and learn from?
<sacarlson>
hemanth: the count of scripts still gives me no clue as to what your final goal is
<sacarlson>
grafthez: I guess I would start with helloworld.rb
<hemanth>
sacarlson, that's true, but what i meant is, the scripts use all most all the methods of watir, so i'm looking into alternative methods as i port to web-driver
<sacarlson>
grafthez: depends on your goals and interests
<grafthez>
I know language basics and all that stuff, but as I come from java I'd like to take a look at some real projects to get more familiar with "ruby way" of writing
twinturbo has joined #ruby
<grafthez>
I'm trying with twitter client but it's quite big
<sacarlson>
grafthez: you can scan github.com and find something that grabs your curiosity that might motivate you to take a look
<sacarlson>
grafthez: so you want to develop some gui applications?
<grafthez>
in general, yes, but for now I'd like to write something in "plain ruby"
<shevy>
but really
<shevy>
the only real way to get better is to write your own code
waseem_ has joined #ruby
mdw has joined #ruby
zommi has joined #ruby
phantomfakeBNC has joined #ruby
<grafthez>
yeah, but you know, coming from language with different style it is tempting to start writing in ruby the java way and I'd like to avoid that as much as possible
<grafthez>
shevy, thanks for slop link, I'll take a look
arvidkahl has joined #ruby
<shevy>
well ruby is like java at 30% lines
JohnBat26 has joined #ruby
<shevy>
so you can keep it the java way but cut down 70% at least of characters used
fabrice31 has joined #ruby
<banisterbaby>
shevy: kiss me beneath the milky twlight
akemrir has joined #ruby
<shevy>
object.method1("bla").method2("ble")
trivol has joined #ruby
<shevy>
banisterbaby, you listen to odd music
dhruvasagar has joined #ruby
AxonetBE has joined #ruby
<sacarlson>
hemanth: from a quick look at http://watirwebdriver.com/ seems the functions havn't changed too much, just that now it supports multiple browsers
jnraine has joined #ruby
<hemanth>
sacarlson, there are few I have come across so far, let see
<hemanth>
for example @browser.contains_text has changed to @browser.text.includes?
Banistergalaxy has joined #ruby
looopy has joined #ruby
Banistergalaxy has joined #ruby
BruceZu has joined #ruby
<sacarlson>
hemanth: I don't see any contains_text in any of my code but I do see this if row[3].text.include?(name) did they change include to includes?
<sacarlson>
hemanth: most of my code of recovering data was from tables
zaydana has joined #ruby
Careott has joined #ruby
arvidkahl has joined #ruby
Careott has joined #ruby
blacktulip has joined #ruby
<hemanth>
sacarlson, another issues is include? does not take R.E :"(
mdw has joined #ruby
GoBin has joined #ruby
<hemanth>
but it says (Boolean) include?(str_or_rx)
<sacarlson>
hemanth: I have no idia what R.E:"( is. you mean you can't have "()" in your string?
<hemanth>
sacarlson, Regular exp
eldariof has joined #ruby
<sacarlson>
hemanth: ok I'm not sure how that would effect any of my code, but watir was quite a small part of my code in that project
bjensen has joined #ruby
thecreators has joined #ruby
<fabrice31>
Hi ! I use watir (and watir-webdriver) since 2 years, and I always do ".include?".
ukwiz has joined #ruby
Banistergalaxy has joined #ruby
arvidkahl has joined #ruby
heftig has joined #ruby
bawer has joined #ruby
fritzthecat_ has joined #ruby
jlebrech has joined #ruby
francisfish has joined #ruby
ickmund has joined #ruby
schaerli has joined #ruby
mengu has joined #ruby
johndbritton has joined #ruby
Ammar01 has joined #ruby
BruceZu has joined #ruby
Jrz has joined #ruby
shruggar has joined #ruby
n1x has joined #ruby
Trumma has joined #ruby
eldariof has joined #ruby
SphericalCow has joined #ruby
<shevy>
fabrice31, that is a common ruby idiom
<shevy>
sacarlson usually include? is an alias to includes?, I think. or vice versa
pi3r has joined #ruby
knopkodav has joined #ruby
roolo has joined #ruby
dql has joined #ruby
crodas has joined #ruby
mdw has joined #ruby
<hemanth>
fabrice31, @browser.text.includes? or @browser.include? i'm porting from watir to watir-webdriver
BiHi has joined #ruby
stefanp has joined #ruby
stefanp has joined #ruby
<fabrice31>
hemanth: @browser.text.include?
DuoSRX has joined #ruby
<hemanth>
fabrice31, @b.text.include?(/trying exp/) TypeError: can't convert Regexp into String
<hemanth>
:(
etehtsea has joined #ruby
bier has joined #ruby
<hemanth>
but the signature says str_or_rx
<hemanth>
fabrice31, we can use regular expressions with include ?
trivol has joined #ruby
<fabrice31>
hemanth: no regexp. What do you want to check in the page ?
waxjar has joined #ruby
Morkel has joined #ruby
<fabrice31>
hemanth: @b.span(:text, /trying regexp/).visible? (or exists?) should help you ;)
<hemanth>
fabrice31, there are many scripts, so it's bit tough to say what exactly i'm looking for
<hemanth>
@b.span only spans, no?
<fabrice31>
yes. That's why I would know what you check.
<fabrice31>
you can do with @b.div too
<hemanth>
oh ho :{
<hemanth>
loads of changes to do then
workmad3 has joined #ruby
tatsuya_o has joined #ruby
<hemanth>
fabrice31, but the signature of includes? says - (Boolean) include?(str_or_rx)
<fabrice31>
I never play with regexp for include? . Perhaps you should ask directly in #watir ;)
<shevy>
hmm when I upload a gem... do I have to include rdoc docu? or will it be automatically generated
<shevy>
or in other words... how do I go about documenting a simple "hello world" .gem?
<hemanth>
fabrice31, #watir is very silent
<fabrice31>
it is more active the afternoon, due to time difference
buschhardt has joined #ruby
eldariof has joined #ruby
<hemanth>
fabrice31, i shall wait :)
SphericalCow has joined #ruby
SphericalCow has joined #ruby
artm has joined #ruby
<hemanth>
"".match vs =~ which wins?
visof has joined #ruby
<arturaz>
chuck testa
<hemanth>
any bot here?
d3vic3 has joined #ruby
Indian has joined #ruby
gokul has joined #ruby
<hemanth>
=~ takes only R.E
<hemanth>
match takes both
<hemanth>
R.E and str
sdeobald has joined #ruby
gtuckerkellogg has joined #ruby
davidpk has joined #ruby
BruceZu has joined #ruby
mikekelly has joined #ruby
akemrir has joined #ruby
fr0gprince_mac has joined #ruby
bwwrd has joined #ruby
heftig has joined #ruby
jenglish has joined #ruby
sectionme has joined #ruby
<shevy>
hemanth =~ wins
LMolr has joined #ruby
<matti>
Hi shevy
<shevy>
die matti
<shevy>
oops
<shevy>
hi matti
<matti>
LOL
<matti>
shevy: I love you too, man.
<matti>
;d
<shevy>
my keyboard is weird, those keys are next to each other
<shevy>
:)
<matti>
:>
<hemanth>
shevy.match('chevy')
<matti>
LOL
Ferdev has joined #ruby
josephwilk has joined #ruby
Whoop has joined #ruby
<shevy>
man
<shevy>
there is no 'c'
josephwilk has joined #ruby
Helius has joined #ruby
bawer has joined #ruby
srji has joined #ruby
pen has joined #ruby
falena has joined #ruby
d3vic3 has joined #ruby
rushed has joined #ruby
rohit has joined #ruby
Helius has joined #ruby
twinturbo has joined #ruby
arvidkahl has joined #ruby
twinturbo has joined #ruby
emmanuelux has joined #ruby
a_meba has joined #ruby
twinturbo has joined #ruby
tvw has joined #ruby
pzol has quit ["Sayonara!"]
twinturbo has joined #ruby
ofcan has joined #ruby
emmanuelux has joined #ruby
fearoffish has joined #ruby
trivol_ has joined #ruby
raincole__ has joined #ruby
tatsuya_o has joined #ruby
dhruvasagar has joined #ruby
trivol has joined #ruby
stephanb has joined #ruby
_adeponte has joined #ruby
nikhgupta has joined #ruby
frishi has joined #ruby
apeiros_ has joined #ruby
jcromartie has joined #ruby
adeponte has joined #ruby
tk___ has joined #ruby
<shevy>
hmm I am bored
simao has joined #ruby
BiHi has joined #ruby
phantomfakeBNC has joined #ruby
pyreal has joined #ruby
odinswand has joined #ruby
<banisterbaby>
shevy: find a pretty girl and make love to her
kf8a has joined #ruby
<shevy>
banisterbaby nah
<shevy>
I need to build me an empire of some sorts
<shevy>
but I begin to wonder if ruby alone is enough for this :(
liluo has joined #ruby
<rohit>
shevy: nodejs!
<shevy>
awwww
<shevy>
do I really have to go back and learn JS :(
<rohit>
shevy: nodejs + coffeescript!
<shevy>
hmmmm
<banisterbaby>
rohit: 'web development' is for fags incapable of real programming
<banisterbaby>
rohit: shevy is interested in lowlevel shit, like C
<rohit>
banisterbaby: I could totally do real programming! :(
<banisterbaby>
rohit: "web developers" run in fear from C
<rohit>
I don't write C but I've seen internals of Ruby. It's not *that* scary.
<shevy>
I will never be able to pass beyond the pointer threshold
<shevy>
but I also dont want to learn Java
<shevy>
I feel stuck :(
<rohit>
I have written C in college of course, but it's not where near the level of stuff that goes on inside mri, sqlite and a couple others I saw
<rohit>
not==no
<shevy>
well I feel there is basic C which is easy
<shevy>
writing and using functions
<shevy>
having to initialize things also seems easy
<shevy>
and then there are pointers and memory :(
<rippa>
pointer arythmetic
mdw has joined #ruby
Banistergalaxy has joined #ruby
simao has joined #ruby
kaysin has joined #ruby
CannedCorn has joined #ruby
rushed_ has joined #ruby
nanderoo has joined #ruby
`brendan has joined #ruby
phantomfakeBNC has joined #ruby
zealinux has joined #ruby
zealinux has quit [#ruby]
ghanima has joined #ruby
jitesh_shetty has joined #ruby
phantomfakeBNC has joined #ruby
emmanuelux has joined #ruby
chimkan has joined #ruby
buschhardt has quit [#ruby]
KL-7 has joined #ruby
KL-7_ has joined #ruby
choffstein has joined #ruby
briankbuckley has joined #ruby
`brendan has joined #ruby
otters has joined #ruby
Synthead has joined #ruby
araujo has joined #ruby
stefanp_ has joined #ruby
francisfish has joined #ruby
tatsuya_o has joined #ruby
jjore has joined #ruby
Sailias has joined #ruby
gtuckerkellogg has joined #ruby
antonishen has joined #ruby
nari has joined #ruby
eldariof has joined #ruby
buschhardt has joined #ruby
chimkan has joined #ruby
jjore has joined #ruby
<pi3r>
hi all
phantomfakeBNC has joined #ruby
<pi3r>
i need some help with block passing
<pi3r>
i have a method that takes an optional block
niku4i has joined #ruby
niku4i_ has joined #ruby
<pi3r>
and if block_given? i want to pass this block to another method
<Tasser>
block_given? or foo(arg, &block); if block
tommyvyo has joined #ruby
<pi3r>
Tasser, yep, but the only way to execute an optional block is by calling yield right?
<Tasser>
pi3r, nope, you can bind the block via &block
<banisterbaby>
pi3r: you on-pass the block by defining an explicit block parameter and passing that to the target method using &block
<Tasser>
def foo(arg, &block); end
<banisterbaby>
pi3r: like this: def hello(&block); other_method(&block) if block; end
<pi3r>
but the block is still optional?
<banisterbaby>
pi3r: Yeah
<banisterbaby>
pi3r: if no block is passed then block is nil
<pi3r>
Oo
<pi3r>
cause i was doing some nonsense like &Proc.new { yield }
<banisterbaby>
pi3r: lulz
<pi3r>
banisterbaby, Tasser let me try that :D
<Tasser>
yet another part where ruby sux: if you pass a method a block, you don't get any warning if it ignores the block as in it never intended to use the block
asobrasil has joined #ruby
<pi3r>
Tasser, yep :D
<pi3r>
and it's really strange that we can't do &block = nil
<banisterbaby>
a relatively minor grievance though, but it is kind of annoying sometimes
<pi3r>
explicitly
<banisterbaby>
pi3r: whta would that mean
<Tasser>
banisterbaby, indeed. but it kind of takes a while to find bugs
<banisterbaby>
Tasser: ;)
zealinux has joined #ruby
<pi3r>
for me a parameter is a required parameter
<Tasser>
like if you do string eval and pass something like "some method" as method name
<Tasser>
pi3r, it isn't for ruby
<pi3r>
a paramater with a default value is not required
<banisterbaby>
[14] (pry) main / PryGit / PryGit::GitHelpers: 2>
<banisterbaby>
Tasser: ^
<Tasser>
you really need a irc client that asks 'do you want to be a jerk [y/N]?'
<pi3r>
so, do there is something wrong with this syntax def foo(options = {}, &block) ?
<banisterbaby>
Tasser: im not being a jerk im being cool
<pi3r>
nevermind
<pi3r>
i'm tired
<Tasser>
banisterbaby, no difference
<banisterbaby>
Tasser: hey check out pry head
<banisterbaby>
Tasser: you might get a surprise ;)
<Tasser>
what's new?
JonSchuff has joined #ruby
<banisterbaby>
Tasser: automatic coloration of typed lines (after enter is pressed)
<banisterbaby>
doesnt need coolline
<banisterbaby>
Tasser: also, when Mon_Ouie (ping ping ping) released the new cooline gem, pry-coolline is now fixed, and auto-indents + up/arrow down arrow work + history works
<banisterbaby>
:D
<banisterbaby>
Tasser: it's pretty sexy i must admit
<banisterbaby>
i love it
<banisterbaby>
Tasser: oh, we also have a brilliant new command, find-method
<banisterbaby>
Tasser: it can find methods by name or by CODE
<banisterbaby>
so they're now more like bash aliases
<Tasser>
thanks, I'll keep my own shell for that :D
<banisterbaby>
Tasser: no i mean for aliases within pry
<Tasser>
ah, right
<banisterbaby>
dont worry, i have no intention to replace bash
<Tasser>
why? fun with pipelines :D
<banisterbaby>
cos it's not within my ambit
yoklov has joined #ruby
LBRapid has joined #ruby
<banisterbaby>
pry is actually quite focussed, even if it doesnt appear that way :) i have a coherent vision for what it is and what it isnt
phantomfakeBNC has joined #ruby
Morkel has joined #ruby
<Tasser>
world domination?
linoj has joined #ruby
<pi3r>
:D
<shevy>
full replacement of irb
<shevy>
:)
<banisterbaby>
Tasser: pry exists primarily to improve itself
briankbuckley has joined #ruby
<shevy>
I intent to replace bash!
<banisterbaby>
Tasser: my main debugging tool for pry is pry itself, i only add features to pry in so far as they make debugging pry easier and more efficient
tatsuya_o has joined #ruby
<shevy>
*intend
<shevy>
world domination will be achieved once I understand pry and embed it
snearch has joined #ruby
dv310p3r has joined #ruby
lorandi has joined #ruby
<shevy>
hmm
<shevy>
there are only 7000 tigers world wide free living still
tatsuya_o has joined #ruby
<shevy>
omg ... qt4 ... 229 MB as .tar.gz
tatsuya_o has joined #ruby
<shevy>
whatever happened to keep things small, simple and beautiful :(
fbernier has joined #ruby
<Tasser>
shevy, I thinka lot of them are docs
friskd has joined #ruby
<shevy>
I shall soon test this! I am going to kill all docs, then repackage
<Tasser>
hmm, installed is 100MB
nikhgupta has joined #ruby
<Tasser>
and qt-docs 335MB
<Tasser>
ehh qt-doc
<shevy>
whoa
<shevy>
335!!!
adeponte has joined #ruby
<shevy>
we are going to break the 1 Gig limit at qt5
_adeponte has joined #ruby
<shevy>
aaaaand kde4 requires boost too
<shevy>
madness, I tell you, maaaaaadness
<Tasser>
shevy, I've heard boost is somewhat of how the stdlib should look like
adeponte has joined #ruby
<shevy>
hehe
<shevy>
I'd just wish it would get included into c++
dbgster has joined #ruby
<shevy>
47M boost-1.49.0.tar.bz2
<shevy>
:(
<heftig>
boost is c++ turned up to 11
<Tasser>
it's lgpl, so don't worry
<heftig>
and that's not a good thin
<heftig>
g
<Tasser>
heftig, what do you mean by that?
<shevy>
hmm why is it not good? (not that I have any idea about it, I am just annoyed that I always have to update boost on my own)
<heftig>
templates templates templates templates
<Tasser>
shevy, why so? package manager does that for you
<shevy>
Tasser nah thanks, I see the problems one gets when wanting to use something like debian + ruby
<shevy>
"how do I use 1.9.3, I am on debian. - You cant."
<Tasser>
that's what archlinux is for
<Tasser>
debian is a stable system, so you get what's stable
<Tasser>
and the ruby ecosystem is around rubygems, which kinda hates any kind of real package management
<Tasser>
that's why so many ruby guys have macs ^^
<banisterbaby>
Tasser: get a mac
<shevy>
wow
<shevy>
you were right Tasser
<shevy>
qt4 is now repackaged into .tar.bz2 at 71M without doc/ directory :)
<Tasser>
banisterbaby, I've got one, but I can't see how you could something like that for coding ^^
<banisterbaby>
Tasser: install eamcs on it and away u go
mstratman has joined #ruby
<Tasser>
apparently nope
CannedCorn has joined #ruby
<shevy>
what editor are you using again Tasser ?
geekbri has joined #ruby
Helius has joined #ruby
bwlang has joined #ruby
fmcgeough has joined #ruby
banisterbaby has joined #ruby
LMolr has joined #ruby
Helius has joined #ruby
<BryanWB>
dear rubyist, can anyone recommend a good stupid simple cucumber tutorial?
mrwalker has joined #ruby
<BryanWB>
emacs or vim ftw, my $0.02, u end up w/ one of them eventually anyways
stoffus has joined #ruby
bbttxu has joined #ruby
netogallo has joined #ruby
Sailias has joined #ruby
swarley has joined #ruby
<Synthead>
what gem provides the class 'Encoding' ?
<swarley>
no gem
<swarley>
its in the STDlib
Fluttershy-- has joined #ruby
<Synthead>
ERROR: While executing gem ... (ArgumentError)
<`brendan>
i figured rm would have been found and known to use the FileUtils
<shevy>
it even has explicit method names
<shevy>
FileUtils.remove_dir
KL-7 has joined #ruby
Guest71832 has joined #ruby
<`brendan>
yeah im just removing files right now
<Mon_Ouie>
I doubt rm_rf cares about whether or not the file exist
<`brendan>
hmm
<Mon_Ouie>
That's what "force" means
cachoimechi has joined #ruby
<`brendan>
File.mtime(f)
<`brendan>
vs FileUtils.mtime
<`brendan>
nm
netrealm has joined #ruby
<`brendan>
so wait
<`brendan>
ahh, File.mtime is already pre-loaded with ruby?
<`brendan>
my requires are only fileutils & chronic
<shevy>
I think File. works
<shevy>
it is unrelated to FileUtils though
<`brendan>
works as in, its accessible without the need to require it?
<shevy>
yeah
<shevy>
you cant create files with it though, I think
<shevy>
I forgot why not :(
<shevy>
oh wait
<shevy>
File.touch "hi"
<shevy>
that seems to work, so I think you can create files with it too?
<bwwrd>
can anyone recommend a good way to create .svg images in ruby? i need to create an .svg file with text in it.
<shevy>
not sure if you can remove anything with it though
<`brendan>
by gosh darnit
<`brendan>
worked
<`brendan>
:/
dpollen_ has joined #ruby
bwlang_ has joined #ruby
mbriggs has joined #ruby
<`brendan>
woohoo
<shevy>
hehe
<`brendan>
i hate scripting delete actions
nikhgupta has joined #ruby
dubios has quit [#ruby]
<shevy>
I like it in ruby
<shevy>
I hate it in shell scripts
alek_b_ has joined #ruby
<`brendan>
if File.mtime(f) < past_time
<`brendan>
FileUtils.rm f unless File.directory?(f)
<`brendan>
end
<`brendan>
that's what i ended up with
<`brendan>
(i know you do the separate functions)
<shevy>
yeah well I'd always put it into a method
<`brendan>
i know i know
tatsuya_o has joined #ruby
<shevy>
yeah, I think it is more convenient that way
<shevy>
you can always modify the method in all your scripts at such a point at a later time
<`brendan>
first script, ill improve each time
<`brendan>
true
<shevy>
:)
jonteru has joined #ruby
dql has joined #ruby
<`brendan>
ty for your help
llaskin has joined #ruby
<shevy>
glad to be of help
waxjar has joined #ruby
rippa has joined #ruby
<jonteru>
hi, I have a problem with the respond_to? function. It is always false. I'm using it on an object returned from a query to another server. Any ideas why it might fail? My usage: e.end.respond_to? :date
<jonteru>
:date
manizzle has joined #ruby
<jonteru>
: date
phantomfakeBNC has joined #ruby
<llaskin>
why would Time.now.strftime("%e-%b-%Y") return an empty string?
mengu has joined #ruby
ckrailo has joined #ruby
<llaskin>
oh i know hah
<llaskin>
cuz %e isn't supported in 1.8.7
<shevy>
jonteru hmm that is odd that you use it like that
<shevy>
I usually see it used in this way:
<shevy>
object.respond_to? :bla
<shevy>
"abc".respond_to? :size # => true
TeckniX has joined #ruby
TeckniX has quit [#ruby]
<jonteru>
shevy: e is an object returned from the query and end is the method
<Mon_Ouie>
And what kind of object is e.end?
yekta has joined #ruby
<jonteru>
it's json result from a query
<shevy>
jonteru well perhaps you call respond_to on the wrong object, .respond_to? definitely works for me
<yekta>
Hello, I'm wondering -- why can't I require a ruby file in the same directory (irb) but I can load 'file.rb' instead? Also doing $: << '.' seems to work but that also seems very dirty.
artm has joined #ruby
<jonteru>
shevy: when i print it: "end"=>{
<jonteru>
"date"=>"2012-04-03"
<jonteru>
},
<jonteru>
but it can't find date
<shevy>
I dont know what this even means
<shevy>
yekta you use ruby 1.9.x ?
liluo has joined #ruby
<shevy>
I also think require "./foo.rb" should work
wmoxam has joined #ruby
llaskin has quit [#ruby]
d2dchat has joined #ruby
mdw has joined #ruby
<yekta>
shevy: Yeah, 1.9.2 and 1.9.3-head
davidcelis has joined #ruby
<robacarp>
yekta: I've run into that before
chimkan has joined #ruby
<robacarp>
load 'file.rb' was the fix
<shevy>
yekta I think they removed the ./ current dir, from 1.8.x to 1.9.x
<wmoxam>
any suggestions on resources for newbs? I'm a little behind on what's considered the best of the best these days
<yekta>
:-/ bummer
<wmoxam>
I'm thiking Ruby Koans
<shevy>
yekta yeah
EzeQL has joined #ruby
<wmoxam>
not sure what else though
<shevy>
yekta convenience vs. "security" :(
<shevy>
I'd try to pick convenience and elegance rather than "security"
<davidcelis>
ruby koans
<shevy>
ruby koalas?
<yekta>
thanks for the input
<davidcelis>
ruby kona coffee
<shevy>
koala coffee!
<davidcelis>
man
<shevy>
they would do something useful for once
<davidcelis>
what is it with you and the koalas
<wmoxam>
davidcelis: I guess the free online pickaxe?
briankbuckley has joined #ruby
mdw has joined #ruby
<davidcelis>
every day, you and these koalas
<wmoxam>
(needs to be free)
<shevy>
davidcelis, I think they are one of the most useless animals... save for the sloth
<davidcelis>
wmoxam: i think the pickaxe is a good reference, but it didn't come off as a good learning guide
<shevy>
without the movie ice age, everyone would hate sloths
<wmoxam>
davidcelis: it has a bit
<davidcelis>
especially for a noob, imo
<wmoxam>
:p
<shevy>
I like chris pine learn to program. one day we should all update it
<wmoxam>
davidcelis: seems like this person is a Java person
<davidcelis>
hm
<wmoxam>
davidcelis: as she put all her methods into classes
<wmoxam>
:p
<davidcelis>
when i tried to look at the pickaxe, i had only dabbled a bit in python, so maybe it's just not very good for an ultra newb?
<davidcelis>
or maybe it just wasnt very good for me haha
<davidcelis>
i ended up learning ruby the wrong way, which was by learning rails, but oh well; i do know ruby now :P
<shevy>
wmoxam that is not a wrong strategy per se ... you can "evolve" classes
<shevy>
I could choose between python and ruby. it was the matz interview that convinced me that ruby was better (because matz seemed smarter than guido hahaha)
<shevy>
but python is ok too
<davidcelis>
I like Python but when comparing the code side by side, I just greatly prefer Ruby
<shevy>
the python docu is still better than the ruby docu IMO
v0n has joined #ruby
<shevy>
yeah
<shevy>
well I like the creativity in the ruby world
<davidcelis>
yeah the ruby community is pretty awesome as well
<davidcelis>
but not you guys
<davidcelis>
you guys suck
BiHi has joined #ruby
gen0cide_ has joined #ruby
baroquebobcat has joined #ruby
<wmoxam>
(I try to help the ppl who fail my programming test)
<wmoxam>
:p
<shevy>
what I like about ideas is that ideas can spawn other ideas. and at least some of these ideas are really awesome
<shevy>
wmoxam, why does this class have no method :(
jfoley has joined #ruby
<wmoxam>
shevy: :(
<cascalheira>
i got quite bored with a couple of rails books i bought. It ended up being easier to do a hands on approach: started a rails project, ended up with a messy project, started to read the manuals again, corrected my mistakes and this way i managed to retain a lot of the new knowledge
jonterzat has joined #ruby
<shevy>
I think a class without methods is a messy thing
<shevy>
methods for me are the central focus point where code can evolve
<wmoxam>
shevy: hence the request for Ruby resources for newbs
<cascalheira>
i know its probably not the best way, but worked with me
<shevy>
(classes I regard as bundled-up collection of methods that share some common things from one to the other)
<cascalheira>
for me*
<shevy>
wmoxam, well just write some methods and play with it, I think writing code is really the best way to get better at ruby
<shevy>
oh yeah, I bought two rails book in total
<shevy>
one I read to page 80
<shevy>
the other not at all
<shevy>
:(
<robacarp>
pshbooks
<cascalheira>
almost the same.
lkba has joined #ruby
<wmoxam>
shevy: yeah, I pretty much suggested that
KL-7 has joined #ruby
alx- has joined #ruby
Phrogz has joined #ruby
<shevy>
wmoxam well, give them some names
<shevy>
I like long, stupid names
<shevy>
def fetch_user_input
<shevy>
that method would fetch all the user input
<shevy>
then the next method would be... something like
<shevy>
def sort_dataset
<shevy>
usually I bundle these methods into a method called
<shevy>
def run
<wmoxam>
shevy: there was never any need to fetch any data
<shevy>
but you wrote that so neatly :)
Molfar has joined #ruby
<wmoxam>
all I asked for was a inplementation of the max method :p
<shevy>
puts "enter five number to check the greatest among from that."
<shevy>
I got all inspired by that man!
<shevy>
it's like a specification :P
<jonterzat>
shevy: if i get the object from each loop with |e| and then check e.end which should have .date method can I use e.end.responds_to? :date ? That should work, right?
<wmoxam>
shevy: I didn't write that dude
<shevy>
awwww
<Molfar>
how can I check if client closed socket before write to it?
Abhinav1 has joined #ruby
<shevy>
jonterzat no idea. I dont use foo.end.method myself, I find it ugly and I avoid ugly in ruby code. it's one of my core rules... "Don't write ugly ruby code." I live by that.
Abhinav1 has joined #ruby
<shevy>
jonteru, Mon_Ouie will surely know though if that works
renanoronfle has joined #ruby
tatsuya_o has joined #ruby
SphericalCow has joined #ruby
<jonterzat>
But how can i check for it differently? Now my app just crashes with nomethod error whenever .date is not found.
ghostlines_ has joined #ruby
<shevy>
hehe
PaciFisT has joined #ruby
<shevy>
sorry, no real idea. I guess whatever object you work on does not have a .date method
KL7 has joined #ruby
<shevy>
first rule of ruby - know the objects you are working with!
<Molfar>
shevy may be you know how to check socket state before writing to it?
<shevy>
Molfar no idea. there should be a method ... .closed? or status or something like that
<shevy>
Molfar, you also did not tell which "client" and which "socket" you use.
choffstein has joined #ruby
<Molfar>
TCPServer and TCPSocket
Brainix has joined #ruby
<jonterzat>
shevy: Well its result.data.items and then i store each item in e with .each but that shouldnt be the problem, right?
<shevy>
argh
<shevy>
jonterzat but then why do you even use .end at all
<shevy>
and if you have an array already, you can work on that
<jonterzat>
Well i have .start.date and .end.date because it is an event and these are the properties
<shevy>
hmmmmm
<shevy>
you have a method called #end in your class?
<shevy>
:\
flagg0204 has joined #ruby
<shevy>
I remember I once did this:
<shevy>
def foo(input, id = '', class = '')
<shevy>
I wondered why this did not work
<jonterzat>
No its not my class. Its data returned from google calendar api.
axl__ has joined #ruby
<jonterzat>
As json and then i convert it to object.
<shevy>
yeah well, no idea. end.something just scares me too much
n1x has joined #ruby
schovi has joined #ruby
<jonterzat>
Yeah i dont know why they did it that way..
ckrailo has joined #ruby
<jonterzat>
shevy, thank you anyway.
chimkan has joined #ruby
<shevy>
jonterzat yeah, good luck man. just keep in mind that .respond_to? works
axl_ has joined #ruby
heftig has joined #ruby
stoffus1 has joined #ruby
MasterIdler_ has joined #ruby
virunga has joined #ruby
mcwise has joined #ruby
mdw_ has joined #ruby
mdw has joined #ruby
twinturbo has joined #ruby
theRoUS has joined #ruby
timonv has joined #ruby
Bonkers has joined #ruby
ooldirty has joined #ruby
Houdini has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
cloke_ has joined #ruby
clocKwize has joined #ruby
iocor has joined #ruby
<clocKwize>
hi
<clocKwize>
does anyone use Whenever?
<clocKwize>
I have 2 applications on one server, and they overwrite each others cron tabs :(
trivol has joined #ruby
luckyruby has joined #ruby
davidcelis has joined #ruby
philips has joined #ruby
daniel_hinojosa has joined #ruby
pzol has joined #ruby
<Tasser>
use different users
<Tasser>
... which you should be doing anyway
j3r0m3 has joined #ruby
cobragoat_ has joined #ruby
eywu has joined #ruby
mong has joined #ruby
robacarp has joined #ruby
mong has quit [#ruby]
Ttech has joined #ruby
Molfar has quit [#ruby]
jameshyde has joined #ruby
ohcibi has joined #ruby
Phrogz_ has joined #ruby
<shevy>
hmm "A belt constrains a human being." Is this proper english at all? "A belt restricts a human being." would be more idiomatic?
<shevy>
The real sentence has to do with unit testing, I want to formulate a sentence that would express that unit testing restricts evolution of code (but as a constraint...)
<luckyruby>
is there a way to assign a hash value based on other values in the same hash? { a: 1, b: 2, c: a+b }
<shevy>
"This constraints... constrains" ... gah :\
artOfWar has joined #ruby
<shevy>
luckyruby, I dont think so
<Phrogz>
restrains, for a seat belt :)
pdtpatrick has joined #ruby
<shevy>
hehe
<shevy>
hmm so the verb is "to strain"?
<shevy>
or am I think about constrict now... oh well, my head is a mess
<shevy>
I am going to listen to epic music from now on when coding in ruby
nu7hatch has joined #ruby
<shevy>
"I wrote this piece of code under the influence of Conan the Barbarian, the original one."
<shevy>
"That piece of code resembles the Here Comes The King soundtrack."
ohcibi has joined #ruby
<shevy>
and for mad code parts, like eval... I will use the joker from The Dark Knight
<Brainix>
My code is mostly inspired by ice cream. :-)
<shevy>
hmm
<shevy>
that could also work for me
SuperNewb1 has joined #ruby
nerdy_ has joined #ruby
zaiste has joined #ruby
wereHamster has joined #ruby
phantasm66 has joined #ruby
savage- has joined #ruby
Araxia has joined #ruby
ohcibi has joined #ruby
zunnyohno has joined #ruby
dhruvasagar has joined #ruby
tatsuya_o has joined #ruby
artOfWar has joined #ruby
PragCypher has joined #ruby
Phrogz_ has joined #ruby
jsaak has joined #ruby
iocor has joined #ruby
cbuxton has joined #ruby
maletor has joined #ruby
adeponte has joined #ruby
SegFaultAX|work has joined #ruby
Guest___ has joined #ruby
artm has joined #ruby
KL-7 has joined #ruby
cobragoat has joined #ruby
mxweas_ has joined #ruby
jlogsdon has joined #ruby
jgrevich has joined #ruby
jgrevich has joined #ruby
zakwilson_ has joined #ruby
fayimora has joined #ruby
jjore has joined #ruby
SegFaultAX|work has joined #ruby
lledet has joined #ruby
Nathandim has joined #ruby
<EvanR>
666 ?
KL-7 has joined #ruby
briankbuckley has joined #ruby
Phrogz has joined #ruby
looopy has joined #ruby
<LMolr_>
I installed a gem from within a ruby script with `gem install xxx` . Why i cannot require it with require xxx right after that?
<arturaz>
because your load path has already been set up
<arturaz>
also there's Gem class if you want to install gems from code
Notimik has joined #ruby
<LMolr>
arturaz: thank you, i'll look into class first
cmarques has joined #ruby
h4mz1d has joined #ruby
ballpointcarrot has joined #ruby
io_syl has joined #ruby
sohocoke has joined #ruby
JohnBat26 has joined #ruby
cool has joined #ruby
pikkachu has joined #ruby
c0rn has joined #ruby
pikkachu has quit [#ruby]
vipaca has joined #ruby
vipaca has joined #ruby
Phrogz_ has joined #ruby
SuperNewb1 has joined #ruby
serenawales has joined #ruby
ed_hz_ has joined #ruby
Phrogz has joined #ruby
dbgster has joined #ruby
<BRMatt>
Hey, is there a ruby shortcut for [a, b].map { |c| a.id } ?
<BRMatt>
Seem to remember seeing one but can't remember it
<matled>
BRMatt: .map(&:id)
YOUR_NICK has joined #ruby
<BRMatt>
cheers matled
<yxhuvud>
that will not give the same answer as the code you pasted.
mbriggs has joined #ruby
jonterzat has joined #ruby
<matled>
yxhuvud: definitely not, but I guess it was just a typo
<yekta>
Hello, I'm trying to require a ruby file in a git post-receive hook, but every time I require or load the file it fails, why can't I require this file? http://pastie.org/private/t6oigcpgbvpt1atjnumya -- I've got RVM installed with 1.9.3-head
<TTilus>
yxhuvud: i bet BRMatt ment c.id
<BRMatt>
doh, yep!
phantasm66 has joined #ruby
<BRMatt>
cheers
CannedCorn has joined #ruby
<Brainix>
Hi, guys. I'm pretty new to Ruby. I normally type "def method(arg)". However, when writing a test method that returns a bool, is it better to type "def test? arg"?
<Brainix>
I'm still trying to get a sense of what's more readable.
adamkittelson has joined #ruby
Progster has joined #ruby
<Brainix>
Or is it better to type "def test?(arg)"?
friskd_ has joined #ruby
<arturaz>
i always use parenthesis
<banisterbaby>
Brainix: Yeah, use a ? method
<arturaz>
it visually separates method name from arg list
tatsuya_o has joined #ruby
<Brainix>
arturaz: Cool, thanks. :-)
ephemerian has joined #ruby
h4mz1d has joined #ruby
schaerli has joined #ruby
kenichi has joined #ruby
<Brainix>
I'm enjoying Ruby so far. :-) I'm coming from the Python world.
<Brainix>
(I loved Python too.)
philcrissman has joined #ruby
<robacarp_>
Brainix: why are you switching?
<Brainix>
robacarp: For work. My new company is a Ruby on Rails shop.
<robacarp>
ah, okay.
voodoofish430 has joined #ruby
brngardner has joined #ruby
<robacarp>
I've been thinking about learning python too.
<robacarp>
haven't done any for years and years
<Brainix>
robacarp: Plus, I'd been using Python for about 3 years. I got a little too "comfortable" with it, if you know what I mean. I needed to learn something new for personal reasons as well.
<Brainix>
But yeah - I still love Python.
chimkan has joined #ruby
ghvandoorn has joined #ruby
manizzle has joined #ruby
<Phrogz>
Brainix: I would love your opinion of Ruby in a year if you've used it. I've twice started to learn Python and then stopped because it felt so unclean. :)
<Phrogz>
Be sure to put coming back here as an experienced Rubyist and Pythonista on your schedule.
looopy has joined #ruby
<robacarp>
pythonista?
<robacarp>
really?
dv310p3r has joined #ruby
briankbuckley has joined #ruby
vereteran has joined #ruby
apok has joined #ruby
qos has joined #ruby
PragCypher has joined #ruby
<Brainix>
robacarp: Yeah, lots of Python hackers refer to themselves as Pythonistas. Maybe a reference to the Sandanistas?
geekbri has joined #ruby
fbernier has joined #ruby
<Brainix>
I've also heard Pythoneers, but that's less common. :-)
<Phrogz>
tbh I didn't know if that was a proper term, or a pejorative one coined by _why :)
stkowski has joined #ruby
shruggar has joined #ruby
<shevy>
hmm
<shevy>
nice pun, Pythoneers
<shevy>
my problem is, I see the snake, and I associate ...
<shevy>
ssszs ssshsssss Sszzs szss
<shevy>
with it. I just can't get it out of my head.
briankbuckley has joined #ruby
<shevy>
what annoys me to no ends is the transition to python 3.x
<shevy>
that is simply no fun :(
<shevy>
I am going to wait until 2.x is either gone, or just not want to learn python
mk03 has joined #ruby
LBRapid has joined #ruby
Helius has joined #ruby
YOUR_NICK has joined #ruby
sdeobald has joined #ruby
chimkan has joined #ruby
brennon_ has joined #ruby
timonv has joined #ruby
<brennon_>
any rack-test users here?
nricciar has joined #ruby
ringotwo has joined #ruby
schovi has joined #ruby
lorandi has joined #ruby
braidn has joined #ruby
mxweas_ has joined #ruby
mrsolo has joined #ruby
<braidn>
hey all looking for some guidance on using nokogiri to parse xml into sql queries. Haven't quite found what I am looking for, thank you for your time
brennon_ has joined #ruby
<any-key>
nokogiri will give you a DOM from an XML document, but it won't generate queries for you
shadoi has joined #ruby
DuoSRX has joined #ruby
<brennon_>
well, if there are any rack::test users here, i'm trying to get some tests running with a sinatra app?.tried to run them with `ruby ./tests.rb` but am just told that no tests were run
<brennon_>
i must be missing something obvious
<brennon_>
if i load it up in irb, i can call the test methods individually
<brennon_>
is there not a 'prepackaged' way to run them all from the command line?
Shamgar has joined #ruby
nu7hatch has joined #ruby
manizzle has joined #ruby
etehtsea has joined #ruby
j3r0m3 has joined #ruby
cobragoat_ has joined #ruby
netogallo has joined #ruby
etehtsea has joined #ruby
asdffdsjaklasdf has joined #ruby
Cache_Money has joined #ruby
<asdffdsjaklasdf>
hey guys
<asdffdsjaklasdf>
i have a question about case statements in ruby
<shevy>
foo = 'hi'
<shevy>
case foo
<shevy>
when /h/
<shevy>
puts 'Yup contains a h.'
<shevy>
end
<shevy>
:)
<asdffdsjaklasdf>
hehe
<asdffdsjaklasdf>
what about formatted like this
<asdffdsjaklasdf>
elfilteredhyst[i] = case
<asdffdsjaklasdf>
when elfiltered[i] > (prev_ele_hyst + hyst): elfiltered[i]
<asdffdsjaklasdf>
when elfiltered[i] < (prev_ele_hyst - hyst): elfiltered[i]
<asdffdsjaklasdf>
else prev_ele_hyst
<asdffdsjaklasdf>
end
<asdffdsjaklasdf>
i translated it to C like this:
<shevy>
should work too and assign to this variable
<shevy>
at least it does not annoy me as much as the
<shevy>
when elfiltered[i] > (prev_ele_hyst + hyst): elfiltered[i]
<shevy>
part
<mstratman>
What's the difference, if any, between `raise StandardError "msg"` and `raise StandardError.new("msg")` Is raise(ex, string) just an alias for ex.new(string) ?
<asdffdsjaklasdf>
hmmm
<Tasser>
mstratman, yep, kind of
<mstratman>
alright then, thanks. :)
<mstratman>
I'll worry about the "kind of" later when/if necessary. ;)
<lectrick>
If "gem list gemname" shows the gem, but IRB >> require 'gemname' says "No such file to load... gemname"... What am I doing wrong?
apeiros_ has joined #ruby
<lectrick>
FYI I use RVM with a brand new gemset
<TTilus>
lectrick: missing require 'rubygems'
<lectrick>
TTilus: require 'rubygems' #=> false. Problem still exists
<lectrick>
(if I try to require the gem after requiring 'rubygems'
kremiak has joined #ruby
<TTilus>
lectrick: ok, dunno then, dont really know about rvm internals and what could go wrong
mxweas_ has joined #ruby
shtirlic has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
looopy has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
davidpk has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
jxpx777 has joined #ruby
Houdini has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
mdw has joined #ruby
h4mz1d has joined #ruby
kremiak has joined #ruby
phantomfakeBNC has joined #ruby
Deele has joined #ruby
kremiak has joined #ruby
bluenemo has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
kremiak has joined #ruby
cmarques has joined #ruby
Boohbah has joined #ruby
axl__ has joined #ruby
bglusman has joined #ruby
twinturbo has joined #ruby
virunga_ has joined #ruby
<Mon_Ouie>
Did you install the gem with --user-install? For some reasons, doing this has never worked for me with RVM
cjlicata has joined #ruby
alex__c2022 has joined #ruby
asuka has joined #ruby
iocor has joined #ruby
axl_ has joined #ruby
<Synthead>
in ruby regex, how do I match things that aren't in a string? like /this/, how can I make it match anything but "this" ?
brngardner has joined #ruby
kpshek has joined #ruby
DPP has quit [#ruby]
<KL-7>
hi there
<Phrogz>
Synthead: You can use a negative lookahead if you don't want it as a particular point.
<Phrogz>
Synthead: But generally, you can't do that well with regex; instead, match the things that *do* match and then exclude them.
<Synthead>
Phrogz: how? !=~ ?
<KL-7>
does ruby 1.8 support source encoding specification via magic comment as 1.9 does?
<shevy>
KL-7 nope
<Phrogz>
Synthead: What are you trying to do?
<KL-7>
shevy, ok, any advices on having the same code base with utf-8 in sources running smoothly both on 1.8 and 1.9?
<Synthead>
Phrogz: compare strings in regexp in an if statement
irk3z has joined #ruby
<Phrogz>
Synthead: I meant the slightly bigger picture.
<Synthead>
Phrogz: anything I describe would be a tangent (honest). Although in the end, I'd be showing or hiding something in a rails app due to a system setting
A_D has joined #ruby
jlogsdon_ has joined #ruby
<Phrogz>
Synthead: OK :)
virunga has joined #ruby
MasterIdler_ has joined #ruby
<shevy>
KL-7 no real idea. I use some ISO encoding myself and avoid UTF. when on 1.9 i use ASCII-BIT or whatever was the name
<Phrogz>
Synthead: It's !~ if you're just testing
<Synthead>
Phrogz: ah-ha! that did it :D
<Synthead>
thanks!
<KL-7>
shevy, ok, thank you. Though, avoiding UTF is not an option in my case.
jlogsdon_ has joined #ruby
lledet has joined #ruby
startling has joined #ruby
jbw has joined #ruby
<denysonique>
Is there a way to make item 'foo' { $app.quit }
<denysonique>
work
<denysonique>
apart from item 'foo', ->{$app.foobar}
<denysonique>
I would like to pass a block to item
<denysonique>
without using do end
theRoUS has joined #ruby
<shadoi>
denysonique: is item your method?
<denysonique>
yes
lorandi has joined #ruby
<shadoi>
def item(var, &block)
<denysonique>
item 'foo' { $app.quit }
<denysonique>
does not work
<denysonique>
syntax error
<denysonique>
the problem here is syntax
<denysonique>
what are the other altarnatives?
looopy has joined #ruby
<shadoi>
use parens
Nss has joined #ruby
<shadoi>
item('foo') { $app.quit }
<shevy>
:P
<denysonique>
hehe
<denysonique>
right
<denysonique>
lol
<denysonique>
thanks man
<denysonique>
forgot about that
atmosx has joined #ruby
<Cache_Money>
what's the default font for gedit in Ubuntu 11.10?
<Cache_Money>
oops
<shevy>
I think ruby needs the () here because it may think this could be a hash perhaps
<denysonique>
probably Ubuntu Cache_Money ↑
<shevy>
Cache_Money COMIC SANS
<shadoi>
shevy: yeah, it's just another argument
<denysonique>
shadoi: Ruby is stupid here (;
<Cache_Money>
shevy: thanks, meant to post it in #ubuntu
<denysonique>
I am making a nice DSL for QtRuby btw
h4mz1d has joined #ruby
Bosma_ has joined #ruby
<denysonique>
menu do
<denysonique>
item('foo') { puts 'hi' }
<denysonique>
end
<denysonique>
this is menu creation
<denysonique>
where foo is the label of the menu item entry
<shadoi>
denysonique: nice
startling has quit [#ruby]
<jlogsdon_>
denysonique: the block is what happens when clicked?
<denysonique>
anyway QtR is going to be my first Gem! Once I have more code I will cut it
otters has joined #ruby
hobodave has joined #ruby
paulmooring has joined #ruby
<paulmooring>
If I require a module, it adds a constant into the Object class. This constant (module name), now runs something when .send(:ModuleName) is called on any object
<paulmooring>
is this expected behavior, and can someone tell me what method is actually running when this happens?
<rippa>
maybe it's a method?
<shevy>
why what how... .send?
<rippa>
I mean, it should be
<rippa>
because #send invokes methods
<shevy>
what module does that?
<paulmooring>
rippa: I'm pretty sure it's not, I have the iptables gem, being used somewhere
<mstratman>
also i like delete_if, though deleting is actually just one of several things done in each iteration. I'm tempted to rethink this whole pattern though (which is: delete and/or modify entries in the hash as they're processed, then at the end of the iteration, what's left indicates the state of things)
becom33 has joined #ruby
Knodi has joined #ruby
axl_ has joined #ruby
Knodi has joined #ruby
nim__ has joined #ruby
<nim__>
hi guys i wanna ask how can i delete the first line of a text file
<anxt>
emacs?
<nim__>
with ruby code
<nim__>
:P
<anxt>
oh
<anxt>
you can still use emacs for that ;)
<bounce>
urgh. so how different is an rspec mock from a factory?
<nim__>
i want a bit of automatically
<nim__>
:P
<anxt>
hmm, i only know how to do it with perl or sed. i cant even compile ruby atm
<anxt>
you could probably read in line by line, run a counter, and print if counter > 1
<anxt>
nim__: no problem, you could easily adapt one under "selective printing of lines"
bwwrd has joined #ruby
hooper has joined #ruby
DrShoggoth has joined #ruby
laen__ has joined #ruby
b26 has joined #ruby
iaj_ has joined #ruby
ereslibre_laptop has joined #ruby
jshsu_1 has joined #ruby
dr_Poggs has joined #ruby
d_roge_ has joined #ruby
CrazyPickles has joined #ruby
Buzzzz has joined #ruby
kalleth_ has joined #ruby
csamuelson has joined #ruby
luxurymode has joined #ruby
hSATAC_ has joined #ruby
jmaister_ has joined #ruby
jmaister_ has joined #ruby
pavelz_ has joined #ruby
bob_f_ has joined #ruby
mlue_ has joined #ruby
sectionm1 has joined #ruby
nimred_ has joined #ruby
r126l_ has joined #ruby
somnium_ has joined #ruby
jcromartie has joined #ruby
Guedes0 has joined #ruby
mdw_ has joined #ruby
svnlto_ has joined #ruby
dfamorato has joined #ruby
mfournier1 has joined #ruby
andrewhl has joined #ruby
carlyle has joined #ruby
axl__ has joined #ruby
majoh has joined #ruby
fr0gprince_mac has joined #ruby
momo-_ has joined #ruby
greyEAX has joined #ruby
briankbuckley has joined #ruby
mythmon has joined #ruby
axl__ has joined #ruby
PhilK has joined #ruby
cjk101010 has joined #ruby
SirFunk has joined #ruby
Nisstyre has joined #ruby
<SIGILL>
Is there a short and simple way for this? if foo[:bar].nil? then foo[:bar] = 0 else foo[:bar] += 1; end
braidn has joined #ruby
bpgoldsb has joined #ruby
<icy`>
x = x.nil? ? 0 : x+1
<icy`>
where x is foo[:bar]
lupine_85 has joined #ruby
<icy`>
hi, i had a question about $VERBOSE = true . Is this really the same as ruby -w ?
<icy`>
I feel like i'm getting more warnings than I should be
<SIGILL>
oh okay - i thought ruby had a special syntax/method for this
jonterzat has joined #ruby
becom33 has joined #ruby
Aristata has joined #ruby
<Aristata>
Anyone here have experience with Prawn PDF rendering?
greenarrow has joined #ruby
lambdan has joined #ruby
davidboy has joined #ruby
<A_D>
I've got a little
<A_D>
Aristata: what do you need?
spanx has joined #ruby
<Aristata>
Well
<Aristata>
I have this massive wall of text
<Aristata>
Well hold on let me restart :)
<A_D>
Is it taking plenty of time to render?
<Aristata>
I have a "resource" that is essentially a page of html, now this page has a main body, and a sidebar.
<Aristata>
No they render fine
<Aristata>
The problem is this:
welterde has joined #ruby
<Aristata>
I am setting aside a set width for the "body" and a set width for the sidebar and saying "render" or whatever
<Aristata>
Now this sidebar is only a page long
<Aristata>
But the body is 3-4
<Aristata>
After the first page the "space" set aside for the sidebar is still there, and it's all blank
<icy`>
(as when i enable warnings i get warnings from hpricot..)
<Aristata>
I need a way to have the second page text fill the whole width
<Aristata>
But I am rendering the whole body at once, and prawn is taking care of the pages
schovi has joined #ruby
<Aristata>
I don't know how to determine mid render that I am on the second page, and to increase the width, if any of that makes sense?
lupine_85 has joined #ruby
<A_D>
mmmm,,, you got something like a summary or a face page right?
shruggar has joined #ruby
tobym has joined #ruby
<Aristata>
I don't follow?
<Aristata>
A face page?
flagg0204 has joined #ruby
bbttxu has joined #ruby
<A_D>
a cover?
schovi has joined #ruby
<A_D>
r u moving down, breaking the page to the second page?
<Aristata>
I am using the text method, so it is automatically making the new page for me.
<Zolrath>
SIGILL`: for your foo[:bar] question
<Aristata>
So lets say I have a million words inserted by the text method, on the first page I want that to have a width of x, but every other page I want x _ 200 or something
<Zolrath>
SIGILL: If you initialize the hash via Hash.new(0) keys will default to 0
<Zolrath>
SIGILL: so foo = Hash.new(0); foo[:bar] += 1; would set foo[:bar] to 1
briankbuckley has joined #ruby
schaerli has joined #ruby
schovi has joined #ruby
<A_D>
Aristata: Perhaps you should divide in two text blocks, the first is your cover page, and the second block the rest with its own style
<Aristata>
Do you now a way to "measure" the text?
<Aristata>
I could eaily split it into an array and do each with a start_new_page
<Aristata>
Like a method that returns this will end up on a new page right here!
brandonsatrom has joined #ruby
<jlogsdon_>
Zolrath: SIGILL, I think it's worth mentioning that if you do that with an instance of any object it will use that single instance for all new values. For example: https://gist.github.com/2287138
<A_D>
to measure the text in words???? like in eloquent ruby???
<A_D>
lol, jk
mlue has joined #ruby
<linduxed>
so i've got a hash that looks like this: foobar = { name: "banana", cost: 100 }
<linduxed>
my question is the following
<linduxed>
could i do something like: amount_of_batches = @ores.select { |ore| ore[current_ore_name] }.cost
<linduxed>
?
<linduxed>
i'm mainly concerned with that .cost part
<linduxed>
because that's what i'm trying to get out
<linduxed>
oh
<jlogsdon_>
linduxed: select would return an array of pairs
<Aristata>
A_D: Well more like a method that returns true, larger_than_page? or something. Because there are line breaks and stuff that may only count as one word, but if they take a whole sentence I can't know for sure
<jlogsdon_>
so you'd have to do .first.cost
<linduxed>
@ores, is an array filled with those hashes i mentioned
<jlogsdon_>
Oh, oh
<jlogsdon_>
yeah, still the same
<jlogsdon_>
select returns an array of all items matching the block
<Zolrath>
jlogsdon_: But that will only mutate a default value that is a string using << instead of +
<linduxed>
so you saw that example with banana? @ores would be an array filled with those
<SIGILL>
Zolrath: that's perfect, thanks a lot!
<jlogsdon_>
also ore[current_ore_name] should be ore[name] == current_ore_name
looopy has joined #ruby
<jlogsdon_>
Zolrath: correct, but i still think it's worth mentioning. it could snag you up if you do what i did
<jlogsdon_>
or something like it
<jlogsdon_>
say a default set with operations like that
<jlogsdon_>
now all your sets are the same
<Zolrath>
true
iocor has joined #ruby
bglusman has joined #ruby
<Zolrath>
Using << with strings definitely tripped me up randomly for a while when I started using Ruby
<Zolrath>
Getting a string from a hash and thinking I was only changing the string I returned, all the while mutating the string in the hash
<A_D>
Aristata: You meant you want to measure the text on the page before you write the text block? something like that?
<A_D>
I'm kinda lost here...
<Zolrath>
SIGILL: No problem!
<jlogsdon_>
yeah, it can trip you up if you aren't used to languages that use references implicitly
<SIGILL>
jlogsdon_: okay, but how is 0 any different from "Hello"? Isn't 0 an object itself?
<jlogsdon_>
you can't modify 0 in place, only do math operations on it
<jlogsdon_>
which makes a copy
asteve has joined #ruby
<jlogsdon_>
classes like String or Set or Array have ways to modify in-place (via #<< or #shift for example), where no dup is made
<SIGILL>
I see. Hence the name "Fixnum"
<jlogsdon_>
ayup[
<jlogsdon_>
it'd be kind of bad if you could change 0 :P
<asteve>
i would like to get the name of the file without the extension File.extname(path) will return ".rb" but how can I get "file" from file.rb without using gsub
<jlogsdon_>
or any literal rep.
<SIGILL>
he, true
<jlogsdon_>
asteve: afaik there's no way without either gsub or substringing it
<jlogsdon_>
a filename include the extension
<jlogsdon_>
otherwise its not a filename, its just a name
<shevy>
hehe
<shevy>
right
jonteru has joined #ruby
<jlogsdon_>
Something like `file[0...(-1 * File.extname(file))]` would work, but its horrible looking
<shevy>
jlogsdon_ is just a name... but jlogsdon_.log man, that keeps track of all his internet connections!
<shevy>
wanna have a peek? :>
<jlogsdon_>
hehehe
<jlogsdon_>
but is it on the http:// or file://? where to look!
jitesh_shetty has joined #ruby
looopy has joined #ruby
jonterzat has joined #ruby
mdw has joined #ruby
buschhardt has joined #ruby
johndbritton has joined #ruby
kvirani has joined #ruby
savr has joined #ruby
<savr>
hi can anyone tell me what the hell is going on here
<klip>
anxt: I would try to find somewhere in /usr/local/lib/ruby/*
<klip>
first
Phrogz has joined #ruby
<klip>
does "more performant" mean faster?
<luckyruby>
klip: yeah
<klip>
you can measure both on large array and see :)
<luckyruby>
can you think of a more performant way of accomplishing the same?
<luckyruby>
than the options i've presented
chimkan_ has joined #ruby
Indian has joined #ruby
<klip>
I would only guess, that first seems to me as faster :) lets try it :)
phantomfakeBNC has joined #ruby
<savr>
LOL I'm an idiot
<savr>
shadoi: I think we all missed the extra # in my paste
<savr>
I bloody commented out the command I was running
headius has joined #ruby
<klip>
haha
nlc has joined #ruby
iocor has joined #ruby
davidpk has joined #ruby
dv310p3r has joined #ruby
wilmoore has joined #ruby
Norrin has quit [#ruby]
lledet has joined #ruby
jlogsdon has joined #ruby
<shevy>
easy errors are good errors
<shevy>
you'll remember them when you run into complex errors
<shevy>
when I had enough of them, I started to rewrite my main project. I am still not finished ... it is so much work ... I should have never tried to make a rewrite ... :(
<savr>
lol
mdw has joined #ruby
savr has quit [#ruby]
carlyle has joined #ruby
jarred__ has joined #ruby
delinquentme has joined #ruby
<delinquentme>
is there a place where you can post code and get critiques ?
<shadoi>
delinquentme: gist.github.com
<delinquentme>
haha true. i mean like a website dedicated to critiquing code ... i guess that anyone in here could work as well
asdffdsjaklasdf has joined #ruby
asdffdsjaklasdf has quit [#ruby]
<shevy>
delinquentme pastie.org !!!
<shevy>
down with gist
dbe has joined #ruby
<jonteru>
hi, i have a problem with google calendar api. I get the result object from it describing the event in the calendar. The problem is that if it's a full day event i have to get the start time like this: event.start.date and if the event is not full day i get the start time like this: event.start.dateTime . I usually get the time with event.start.dateTime but when it's a full day event i get nomethoderror. How could i check if dateTime or date is av
<shevy>
yes, put it on pastie.org and I shall bitch professionally about it delinquentme :)
<delinquentme>
deal shevy
<shevy>
but actually
<shevy>
if github would have such a feature
<shevy>
I'd not mind. imagine if people would give critique about projects at github
<klip>
luckyruby: http://pastie.org/3717144 test1 is little bit faster then test2 here on my computer :)
<shadoi>
delinquentme: I really recommend you check out json-schema
<shadoi>
delinquentme: it would make a lot of this a TON more sane.
<luckyruby>
klip: can you try result.concat supported_cartypes.map { |i| i.name if i.position.to_i >= minimum_cartype.position }
<luckyruby>
as test3
raz has joined #ruby
stephenjudkins has joined #ruby
byronb has joined #ruby
<delinquentme>
shadoi, shevy talk to me about the use of instance vars... are those appropriate or not?
jarred_ has joined #ruby
Phrogz has joined #ruby
<klip>
luckyruby: test3 is little bit slower then test2 :)
<shadoi>
delinquentme: not if you're not using a class
<sarmiena_>
how would I join several predefined regexes into an or regex? e.g. reg = [/^a/, /^b/]; "a".match(???)
<shadoi>
delinquentme: and redefining main is ugly too
iocor has joined #ruby
<klip>
luckyruby: but it might depend on cartype object, what positions it usualy contains :)
<shadoi>
delinquentme: make a class for this, don't monkey patch string (just add a class method or something), rescue proper exceptions instead of using multiple begin .. rescue .. end blocks
<klip>
and on minimum_cartype.position
<klip>
not sure, I'm not sober :)
yoklov has joined #ruby
SolarisBoy has joined #ruby
<delinquentme>
shadoi, so im not sure how they're going to except is the issue
<delinquentme>
basically if they dont fit the normal formatting I want to know
<delinquentme>
and should I just name main something else?
<shadoi>
delinquentme: make it a class.
vipaca has joined #ruby
<shadoi>
delinquentme: find out the exceptions that get raised and handle them, and then handle ALL other exceptions in a graceful way.
<delinquentme>
kk i think i follow
Phrogz has joined #ruby
<delinquentme>
on the exceptions part
<delinquentme>
so you're saying make this entire operation into a class instead of using main? then just instantiate the class
<shadoi>
delinquentme: you can have multiple rescue lines in a begin .. rescue .. end block
<delinquentme>
perhaps a class for journals
<shadoi>
delinquentme: and you can use "ensure" in there to make something happen no matter what occurs.
ozymandius has joined #ruby
mdw has joined #ruby
<delinquentme>
Class <Publisher>_Journal
dhruvasagar has joined #ruby
<delinquentme>
ya
<shadoi>
no underscores in class names
jitesh_shetty has joined #ruby
iocor has joined #ruby
<shevy>
delinquentme sorry, had a tiredness attack unrelated to here
RangerMauve has joined #ruby
<shevy>
sometimes that happens when I sit too long in front of a computer
mxweas_ has joined #ruby
kryptek has joined #ruby
<delinquentme>
lol np
<RangerMauve>
Hey, is there a built in function to compare if to strigns are the same while ignoring case?
<shevy>
delinquentme I dont really see instance variables there
<shevy>
it seems somewhat unstructured code
<RangerMauve>
like 'Butts'.eqlish?('buttS')
<shevy>
like you wrote only 3 methods
<shevy>
and no class on your own (only modified class String)
<shevy>
sorry, gotta leave again, my right eye has a problem
andrewhl has joined #ruby
jbhewitt has joined #ruby
<delinquentme>
shevy, so you would have written some class for this and then used the valid_json? as a method for that class
<jlogsdon>
RangerMauve: no. 'Buttes'.downcase == 'bUttes'.downcase would be it
<jlogsdon>
Regex would be the more unreadable form, imo. "Buttes" =~ /#{other_string}/i. Unless he was just using literals, but thatd be a strange time to have to check :P
<shadoi>
str =~ /#{str}/i
<jlogsdon>
str =~ /^#{str}$/i actually
<jlogsdon>
that would make "buttes" match "i am full of buttes and stuff"
<RangerMauve>
What does the /i do?
<shadoi>
sure
<jlogsdon>
case-insensitve search
<RangerMauve>
Cool, I'll try that, but the situation is a bit strange
macmartine has joined #ruby
mk has joined #ruby
d3vic3 has joined #ruby
artOfWar has joined #ruby
tatsuya_o has joined #ruby
keymone_ has joined #ruby
CannedCorn has joined #ruby
mk has quit ["Leaving"]
alphabitcity has joined #ruby
anxt has quit ["ERC Version 5.3 (IRC client for Emacs)"]
<alphabitcity>
what do you call it when you have conditional returns in a method before logic? e.g. return if x == true; code goes here
<sam113101>
can I pass by reference
<shadoi>
alphabitcity: bad code?
<shadoi>
alphabitcity: ;)
<alphabitcity>
shadoi: indeed, but there's a name for that
<RangerMauve>
Shode
lkba has joined #ruby
<shadoi>
alphabitcity: I don't think there's an official name for it, "early return" seems to fit.
<alphabitcity>
shadoi: sounds good to me, thanks :]
<shadoi>
alphabitcity: there are certain situations where it makes the most sense.
<alphabitcity>
shadoi: mind giving an example?
<shadoi>
sort of like goto in C
<RangerMauve>
That's horrifying.
<shadoi>
alphabitcity: boolean returns sometimes make sense like that.
<alphabitcity>
ok, thanks
<shadoi>
return true if (implicitly return false if it fails...)
<shadoi>
but there's usually a better way of writing it I'd say.
<sam113101>
how do I pass something by reference, to a function
Narcissus has joined #ruby
Narcissus has joined #ruby
<RangerMauve>
Just pass it regularly
<RangerMauve>
It's always a reference unless you duplicate it
<sam113101>
really?
<RangerMauve>
Try it
<RangerMauve>
Make an object with soem random instance variable
<RangerMauve>
set it to something and try to change it within some function
mdw_ has joined #ruby
briankbuckley has joined #ruby
<sam113101>
irb(main):001:0> def test(x)
<sam113101>
irb(main):002:1> x = 2
<sam113101>
irb(main):003:1> end
<sam113101>
=> nil
<sam113101>
irb(main):004:0> y = 3
<sam113101>
=> 3
<sam113101>
irb(main):005:0> test(2)
<sam113101>
=> 2
<sam113101>
irb(main):006:0> y
<sam113101>
=> 3
<sam113101>
irb(main):007:0>
<RangerMauve>
o-o....
<sam113101>
wait
<sam113101>
lol wait
<RangerMauve>
Err try pastie
<sam113101>
irb(main):007:0> test(y)
<sam113101>
=> 2
<sam113101>
irb(main):008:0> y
<sam113101>
=> 3
<sam113101>
irb(main):009:0>
brngardner has joined #ruby
<RangerMauve>
Jesus that is illegible
<sam113101>
next time I promise
<sam113101>
why
<RangerMauve>
Er one sec
<shadoi>
sam113101: if I had ops you'd be kicked. :)
<sam113101>
but but
<sam113101>
people never click on my pasties
<RangerMauve>
I will
<davidcelis>
dude you dont click on a pastie
<sam113101>
and no one's talking anyway
<davidcelis>
you eat it
<davidcelis>
pasties are for eating ಠ_ಠ
<RangerMauve>
It's just hard to read in the chat
<shadoi>
sam113101: it's the channel rules.
<shadoi>
and it's annoying as hell.
<sam113101>
basically my test function doesn't change the value
philcrissman has joined #ruby
<shadoi>
sam113101: in your code you're setting x regardless of what's passed in.
<shadoi>
and x is local.
<RangerMauve>
Define a class with an instance variable
<davidcelis>
sam113101: dude not how variables work
<RangerMauve>
I didn't test it before hand though.
<shadoi>
sam113101: you should really go through the tryruby.org tutorial, the last 2 chapters are on classes.
<sam113101>
I know what instance variables are, but I wanted to pass by reference instead
<RangerMauve>
What do you mean?
<shadoi>
sam113101: you don't do it instead, it's ALWAYS done.
serenawales has joined #ruby
<RangerMauve>
It's always a reference
<sam113101>
well it seems like everything is passed by value
<RangerMauve>
No it's all passed by reference
<shadoi>
sam113101: in the example you did, you're creating a NEW local variable for that method
<RangerMauve>
You just create a new class when you assign it a new value
<sam113101>
ah
<sam113101>
I think I understand
brngardner has joined #ruby
h4mz1d has joined #ruby
adeponte has joined #ruby
Squarepy has joined #ruby
<shadoi>
sam113101: you can check that objects are references by calling object.object_id
carlyle has joined #ruby
Squarepy has joined #ruby
moted has joined #ruby
_main_ has joined #ruby
dbe has joined #ruby
brngardner has joined #ruby
<linduxed>
how do i do "assuming that i've got a number x, if the key :banana exists in hash foobar, then add x to the value of the key. if the key doesn't exist, then create the key and use x as the value"
<RangerMauve>
Well break it down
<RangerMauve>
You have an if statement in there checking if the hash has the key out want
<RangerMauve>
so foobar.key?(:banana) for that
<klip>
has_key?
<klip>
ah, its same
<RangerMauve>
I find key? is faster to type =P
<klip>
well, didn't know it is alias :)
mdw has joined #ruby
alphabitcity has quit [#ruby]
Nanuq has joined #ruby
sbanwart has joined #ruby
tatsuya_o has joined #ruby
Chryson has joined #ruby
andrewhl has joined #ruby
adeponte has joined #ruby
lordzero has joined #ruby
IPGlider has joined #ruby
__main__ has joined #ruby
jbhewitt has joined #ruby
dhruvasagar has joined #ruby
wroathe has joined #ruby
<wroathe>
What is instance_exec used for in practice?
<banisterbaby>
wroathe: basically for evalling a block as if it was a method
headius has joined #ruby
t0mmyvyo has joined #ruby
Indian has joined #ruby
berserkr has joined #ruby
<shadoi>
banisterbaby: wouldn't you use instance_eval for that?
fowl has joined #ruby
<banisterbaby>
shadoi: nah instance_eval cant take parameters ;)
<shadoi>
ah
manizzle has joined #ruby
<shadoi>
hmm
<banisterbaby>
shadoi: instnace_eval("sup baby") { |x| puts x }
<shadoi>
I guess I've never run into that
<banisterbaby>
instance_exec even*
<shadoi>
I always use it for little DSL-like things
<banisterbaby>
shadoi: you dont need it often, but when you do it's pretty awesome :)
<banisterbaby>
shadoi: i also just prefer it to instance_eval
<banisterbaby>
as instance_eval can't take lambdas anymore
<shadoi>
yeah I can see some uses for it right now in my current project acutally.. :)
<shadoi>
actually*
macabre has joined #ruby
shaggy2dope has joined #ruby
phantasm66 has joined #ruby
<shadoi>
ah, I just used class instantiation instead of _exec
<shadoi>
Foo.new(opts) do .. end
<wroathe>
banisterbaby: So the idea is that if you have a method that accepts &block then potentially you'd want to use instance_exec to execute the block within your method.
dhruvasagar has joined #ruby
<wroathe>
Are there any other ways to execute the &block in that context?
<banisterbaby>
wroathe: usually i use it for storing and executing later on
<banisterbaby>
delayed execution
<shadoi>
hah, I got around it using instance_eval by doing Proc.new(&block).call
<shadoi>
jesus
<shadoi>
I'll change that now :)
<banisterbaby>
wroathe: have you used sinatra?
<wroathe>
No
<fowl>
wroathe is a newbie lol
andrewhl has joined #ruby
mdw has joined #ruby
<wroathe>
He caught me. I've been outed.
<wroathe>
Yeah. I'm only about three months into my Ruby career.