<johnjgrieco>
Very new to this, Thanks for any help
JPascal has quit []
JPascal has joined #ruby-lang
JPascal has quit [Client Quit]
JPascal has joined #ruby-lang
JaReAx has quit [Ping timeout: 258 seconds]
ta has joined #ruby-lang
fezziwig has quit [Remote host closed the connection]
<johnjgrieco>
Is the code legible?
fezziwig has joined #ruby-lang
<ari-_-e>
not really
|jemc| has quit [Ping timeout: 258 seconds]
<johnjgrieco>
When I click the link it looks pretty neat on the github site
nkirkwood has joined #ruby-lang
<johnjgrieco>
Did you try running it?
<ari-_-e>
no
<ari-_-e>
I'm just looking at the gist
<ari-_-e>
the indentation is inconsistent
<nkirkwood>
Hello. Does anyone have experience with accessing ODBC with ruby. Specifically FileMaker
<johnjgrieco>
I know that might make it not very neat but it doesn't really make the code not work right?
JaReAx has joined #ruby-lang
scepticulous has joined #ruby-lang
<ari-_-e>
johnjgrieco: the interpreter will have no trouble with it, but the people you're asking for help from might have different feelings :)
fezziwig has quit [Ping timeout: 240 seconds]
<johnjgrieco>
Yeah, and for that I apologize:) Do you think you'll be able to help?
sharpmachine has joined #ruby-lang
<ari-_-e>
well, you haven't even said what your issue is
smiams has joined #ruby-lang
smiams has left #ruby-lang [#ruby-lang]
woollyams has quit [Ping timeout: 252 seconds]
zlogan has joined #ruby-lang
<johnjgrieco>
The first set of code runs great, then I tried to add another item for my player to collect (acorns) and it fails, I get an error having to do with ZOrder, a module I created
alexju_ has quit [Remote host closed the connection]
<johnjgrieco>
Also my terminology is most likely not accurate so bare with me
<ari-_-e>
what error?
<johnjgrieco>
NameError
<ari-_-e>
the full error
<ari-_-e>
paste it if it's long
woollyams has joined #ruby-lang
[spoiler] has joined #ruby-lang
sharpmachine has quit [Remote host closed the connection]
woollyams has quit [Ping timeout: 252 seconds]
amclain has quit [Quit: Leaving]
ta has quit [Ping timeout: 252 seconds]
<johnjgrieco>
Imain.rb:54:in `draw': uninitialized constant DCTGame::ZOrder (NameError) from main.rb:171:in `<main>'
<johnjgrieco>
Yeah, it made it much easier to understand what I was ending, am I missing some? Or have too many?
<ari-_-e>
count em :)
<johnjgrieco>
Okay I added one
<ari-_-e>
sweet
ironhide_604 has joined #ruby-lang
<johnjgrieco>
I ran the code again and it seemed to have helped, I saw a glimps of life but then it gave me a different error
<johnjgrieco>
in `draw': divided by 0 (ZeroDivisionError) from main.rb:56:in `block in draw' from main.rb:56:in `each' from main.rb:56:in `draw' from main.rb:171:in `<main>'
<ari-_-e>
what's the first line num?
<johnjgrieco>
163
<ari-_-e>
so there's only one candidate there
<ari-_-e>
for what could be 0
<johnjgrieco>
Lol, I'm not dividing anything by zero on that line though
cnivolle has quit [Remote host closed the connection]
<johnjgrieco>
And I did it exactly the same on the Shroom class and no errors
<johnjgrieco>
line 144
cnivolle has joined #ruby-lang
<ari-_-e>
you're right - in fact, those classes are almost identical
<johnjgrieco>
Yeah so why would I have issues with just one?
<johnjgrieco>
I want them to do the exact same thing
mistym has quit [Remote host closed the connection]
<johnjgrieco>
Just with a different image
<ari-_-e>
well why don't you merge them? if you want them to do the same thing, that seems logical
ta has quit [Ping timeout: 265 seconds]
[spoiler] has quit [Remote host closed the connection]
<johnjgrieco>
Okay, sounds like a good plan
<johnjgrieco>
Work me through it?
<ari-_-e>
well, how are they different?
<johnjgrieco>
The image will be different and the pixels that they appear in will be different
<ari-_-e>
doesn't look like it to me
cnivolle has quit [Ping timeout: 258 seconds]
<ari-_-e>
don't think about how exactly you're using them
[spoiler] has joined #ruby-lang
<ari-_-e>
when it comes to merging them, you want to look at the code differences
dingus_khan has joined #ruby-lang
<johnjgrieco>
There are no code differences
<ari-_-e>
I see one
<johnjgrieco>
Class name
<ari-_-e>
well yeah
<ari-_-e>
two :)
<johnjgrieco>
ZOrder
<ari-_-e>
right
<johnjgrieco>
That is where I was having the error in the first place
<ari-_-e>
the first error?
<johnjgrieco>
Yeah
<ari-_-e>
well you fixed that
<ari-_-e>
ancient history
<johnjgrieco>
Yeah
<ari-_-e>
so they have different ZOrders
<johnjgrieco>
Right
<ari-_-e>
can you think of a way to factor that out?
banister has joined #ruby-lang
<johnjgrieco>
I thought I did that by adding acorns to the module
<ari-_-e>
did what?
<johnjgrieco>
Line 127
banister has quit [Client Quit]
<johnjgrieco>
The constants, right?
<ari-_-e>
yeah
<ari-_-e>
I see that there's an Acorns constant
<johnjgrieco>
lol
<ari-_-e>
:)
<johnjgrieco>
Obviously didn't help with the merging
<ari-_-e>
I meant the different ZOrders
ta has joined #ruby-lang
<ari-_-e>
how could you factor out the ZOrder difference from those two classes?
<ari-_-e>
because once that's gone they'll be identical, right?
woollyams has joined #ruby-lang
<johnjgrieco>
Create another class?
<johnjgrieco>
or def zorder?
<ari-_-e>
johnjgrieco: what is different about different instances of Shroom or Acorn?
<ari-_-e>
actually...
<ari-_-e>
hmm
<ari-_-e>
johnjgrieco: before, you said that there were some differences in how you were using Shroom and Acorn, what were they again?
<johnjgrieco>
I'll be using them exactly the same, they are both items for my player to pick up, just different images
<ari-_-e>
right
ta has quit [Remote host closed the connection]
<ari-_-e>
and how are you telling them to have different images?
moogumbo has quit [Quit: Connection closed for inactivity]
<johnjgrieco>
in the @acorn_anim
<johnjgrieco>
Created an Acorn class and gave it its own animation
<ari-_-e>
and Shroom also, right?
<johnjgrieco>
Yes
<ari-_-e>
could you do that same thing with the ZOrder?
<johnjgrieco>
Make ZOrder a class and put both animations in it?
JohnBat26 has joined #ruby-lang
woollyams has quit [Ping timeout: 252 seconds]
<ari-_-e>
no, give Acorn/Shroom their ZOrders
<ari-_-e>
like you did with their animations
<johnjgrieco>
I thought thats what I did
<johnjgrieco>
Each one has ZOrder
<ari-_-e>
do you see how you're passing in the animations?
ledestin has joined #ruby-lang
<johnjgrieco>
Yes, through draw right?
<ari-_-e>
say you're creating an Acorn
<ari-_-e>
an Acorn instance
<ari-_-e>
do you see how you set that instance's animation?
<ari-_-e>
did you write this code?
solars has joined #ruby-lang
dingus_khan has quit [Read error: Connection reset by peer]
<johnjgrieco>
I was following a tutorial and then I decided to try and take if further.
lsegal has quit [Quit: Quit: Quit: Quit: Stack Overflow.]
<johnjgrieco>
I have already emailed the creator but stopped by hear for help
<johnjgrieco>
I am trying to understand
knu has joined #ruby-lang
<ari-_-e>
johnjgrieco: I see, so this comes from the Star class?
GBrawl has joined #ruby-lang
<johnjgrieco>
Yeah
<johnjgrieco>
But I tried to add another star class (acorn) the same way and here we are
<ari-_-e>
johnjgrieco: if this is your first time coding, you might not want to start with this
<johnjgrieco>
I learn better by starting with harder stuff...
<ari-_-e>
I think this is for people who want to learn how to use gosu with ruby, not for people who are new to programming
<ari-_-e>
well it's not telling you anything about object-oriented programming or anything
<ari-_-e>
which is important
<johnjgrieco>
I understand that this is not for people new to programming but Gosu does seem to be a beginners tool to creating something tangible from code.
<johnjgrieco>
I would really like to know how to add another (star) to my game....
<ari-_-e>
johnjgrieco: does Acorn.png actually exist?
<johnjgrieco>
Yes
<ari-_-e>
how big is it?
knu has quit [Ping timeout: 252 seconds]
<johnjgrieco>
pixel size or file size?
<ari-_-e>
and how big is shroom.png?
<ari-_-e>
pixel size
<ari-_-e>
dimensions
<johnjgrieco>
25, 25
<johnjgrieco>
small
<johnjgrieco>
I can send you a video of the working game with the shrooms
<johnjgrieco>
So you have an idea of whats going on
<ari-_-e>
so they're the same dimensions?
<johnjgrieco>
Yes
<ari-_-e>
hmm...
<johnjgrieco>
Seemed like a good size, the shrooms look perfect
<johnjgrieco>
The background is a forest, so the shrooms pop up on the forest floor
toastynerd has quit [Remote host closed the connection]
<johnjgrieco>
I want Acorns to pop up in the trees
<johnjgrieco>
I know I have them set to both appear in the same area but I was going to change that when I got them to appear at all
gregf_ has quit [Quit: leaving]
<ari-_-e>
johnjgrieco: ok, well do you see what must be zero on line 163 for you to be getting this error?
<ari-_-e>
also: do you know what the % operator does?
<johnjgrieco>
milliseconds?
<ari-_-e>
it's division by zero
<ari-_-e>
are you divising by milliseconds?
<ari-_-e>
dividing
adphillips has joined #ruby-lang
adphillips has quit [Remote host closed the connection]
<johnjgrieco>
oh, @animation.size
<ari-_-e>
yeah
mikecmpbll has joined #ruby-lang
<ari-_-e>
there is another possibility actually, that I had to check: are you familiar with the term operator precedence?
ta has joined #ruby-lang
<johnjgrieco>
Yes, kind of, the order that the language does things in?
<johnjgrieco>
Which operator goes first
<ari-_-e>
it's the order that the operators are evaluated in, yes
<ari-_-e>
it could have been that the % was evaluated first, and the 100 % @animation.size resulted in zero, causing the division by zero
mikecmpbll has quit [Client Quit]
<ari-_-e>
but that's not the case - / and % actually have the same precedence, and in this case the operators are evaluated left to right
<ari-_-e>
so the / is evaluated first
<ari-_-e>
each group of operators that have the same precedence have something called "associativity" which says what direction operators of the same precedence are evaluated in
<ari-_-e>
*, / and % have the same precedence and their associativity is left to right
Fushi has joined #ruby-lang
<johnjgrieco>
Right, I found that, got it
<johnjgrieco>
So thats not an issue
<ari-_-e>
right, so the problem is @animation.size
<johnjgrieco>
Yeah but it works just fine with the Shroom class...
<ari-_-e>
which brings us back to where @animation comes from :)
frzng has quit [Quit: frzng]
<ari-_-e>
do you know what the @ means?
Mon_Ouie has joined #ruby-lang
Mon_Ouie has quit [Changing host]
Mon_Ouie has joined #ruby-lang
<johnjgrieco>
So how did I set that instance's animation?
<ari-_-e>
right
charliesome has quit [Read error: Connection reset by peer]
charliesome_ has joined #ruby-lang
skade has joined #ruby-lang
<johnjgrieco>
So how did I? lol
<ari-_-e>
do you know what the @ means?
tbuehlmann has joined #ruby-lang
mikecmpbll has joined #ruby-lang
fezziwig has joined #ruby-lang
skade_ has joined #ruby-lang
<johnjgrieco>
I don't
<johnjgrieco>
Variable in a class?
michd is now known as MichD
skade has quit [Ping timeout: 240 seconds]
<ari-_-e>
in an instance
<ari-_-e>
it's an instance variable
fezziwig has quit [Ping timeout: 240 seconds]
<johnjgrieco>
Got it
<ari-_-e>
do you see where it is set?
<johnjgrieco>
Yes, it's set twice, once under Shroom class and another under Acorn class
havenwood has quit []
<ari-_-e>
well, every instance has its own instance variables
<johnjgrieco>
Okay got it
<ari-_-e>
so those aren't the same variable
<ari-_-e>
in fact, every time either of those pieces of code run it's a new variable
Cakey has joined #ruby-lang
<ari-_-e>
but yes
<johnjgrieco>
Okay so I should change the name of one of them?
<ari-_-e>
no
<ari-_-e>
they're already different
<ari-_-e>
what methods are they set in?
<johnjgrieco>
Initialze
<ari-_-e>
and do you know when initialize is called?
<johnjgrieco>
I don't
<johnjgrieco>
Like what order?
<johnjgrieco>
Or when in the program is it called?
<ari-_-e>
what would you have to do for that method to be called
<johnjgrieco>
end?
<ari-_-e>
it's an initializer for instances
<ari-_-e>
it's called when you create an instance
<ari-_-e>
to initialize it
<johnjgrieco>
got it, in this case, @animation
<ari-_-e>
it does a few other things
Cakey has quit [Ping timeout: 265 seconds]
<johnjgrieco>
right
<ari-_-e>
where in the program do instantiate Acorn?
wallerdev has quit [Quit: wallerdev]
<ari-_-e>
*do you
<johnjgrieco>
in the game class
<johnjgrieco>
Right?
<ari-_-e>
yeah
<ari-_-e>
what line
<johnjgrieco>
16
<ari-_-e>
no
<johnjgrieco>
oh yeah 15
<ari-_-e>
also no
<johnjgrieco>
Under draw?
<ari-_-e>
nope
Cakey has joined #ruby-lang
<johnjgrieco>
56?
<ari-_-e>
to instantiate Foo, you do Foo.new(arguments)
<ari-_-e>
that creates a new instance of Foo
<ari-_-e>
you would have to reference Foo somehow
<ari-_-e>
or Acorn
<ari-_-e>
lines 15, 16, and 56 do not reference Acorn
<maloik>
and all of a sudden it decides to start sending emails for failed builds
<maloik>
as in, all failed builds, ever
<maloik>
125 mails in 2 mminutes and counting
<ari-_-e>
johnjgrieco: almost all programming languages are case-sensitive
<ari-_-e>
the ones that aren't aren't worth bothering with
<johnjgrieco>
Okay so I have lowercase a for acorn and I should capitalize it?
<ari-_-e>
...no
<ari-_-e>
we're trying to find where Acorn is currently instantiated
<ari-_-e>
you haven't found it
<ari-_-e>
remember how I said Foo.new instantiates Foo?
<johnjgrieco>
ah line 46
<ari-_-e>
yes
<ari-_-e>
the arguments to .new are passed to initialize
qba73 has joined #ruby-lang
<johnjgrieco>
Got it
<ari-_-e>
so where does @animation come from?
phansch has joined #ruby-lang
<johnjgrieco>
I figured it out! You helped so much
<johnjgrieco>
line 45
<johnjgrieco>
acorn size was set < 25
<johnjgrieco>
the actual pixels were higher than 25
<johnjgrieco>
I changed the image size to lower than 25 pixels and now i have acorns
<ari-_-e>
hmm...
<johnjgrieco>
the image file for acorn was 23 x 37 pixels
<ari-_-e>
I asked you what the size was :-/
<johnjgrieco>
I changed it to 25 X 25
<johnjgrieco>
Yeah, I had it saved incorrectly
<ari-_-e>
hmm
<ari-_-e>
ok
<johnjgrieco>
Thank you so much!
<johnjgrieco>
You would be a great teacher
<ari-_-e>
well, the @acorns.size < 25 on line 45 isn't the cause
mehlah has joined #ruby-lang
<ari-_-e>
@acorns.size isn't the size of the image
tomkadwill has joined #ruby-lang
<yorickpeterse>
morning
toastynerd has joined #ruby-lang
Missphoenix has quit [Quit: Leaving]
<johnjgrieco>
Oh okay, well maybe it was holding me to the 25, 25 on line 15
<ari-_-e>
johnjgrieco: that would be my guess
<ari-_-e>
that's why I asked about the size of the image
<johnjgrieco>
Yeah I was going through your comments above and I rechecked the size and sure enough it was wrong
toastynerd has quit [Ping timeout: 240 seconds]
<johnjgrieco>
Thanks for all of your help
<johnjgrieco>
You have the patience of a saint
<johnjgrieco>
Any ideas on how to package this into a DMG file so that others can view my game?
<ari-_-e>
johnjgrieco: is this for a class?
<johnjgrieco>
Yeah
<johnjgrieco>
I finished the Ruby Codecadamy but didn't learn very much, then I decided to mess around with making a simple game
<ari-_-e>
have you not been taught anything about ruby in your class...?
<johnjgrieco>
Learning curve is pretty brutal
<ari-_-e>
what was the assignment exactly?
Cakey has joined #ruby-lang
<johnjgrieco>
Follow an online programming course, which I finished in like a week, then mess around the language you learned
<johnjgrieco>
I need some sort of theory
<johnjgrieco>
This is a very small part of my class
<johnjgrieco>
Programming/Software Anthropology/hardware/lecture series
<johnjgrieco>
ari-_-e: Thanks for the help! I'm sure i'll be back;)
<johnjgrieco>
Have a good night or morning.
workmad3 has joined #ruby-lang
<johnjgrieco>
In Washington its 2 am
alex-quiterio has joined #ruby-lang
<ari-_-e>
in massachusetts it's 5am
<johnjgrieco>
Time for bed? Or are you just starting your day?
<johnjgrieco>
ari-_-e: Also, what path did you take in learning Ruby, or any language in general?
<ari-_-e>
hah well I've been talking to you since 1:30am my time, so...
Cakey has quit [Ping timeout: 252 seconds]
Cakey has joined #ruby-lang
<workmad3>
ari-_-e: so time for lunch? :)
<johnjgrieco>
Haha
<ari-_-e>
~_~
kitak_ has quit [Ping timeout: 240 seconds]
Miphix has joined #ruby-lang
kitak_ has joined #ruby-lang
Cakey has quit [Ping timeout: 240 seconds]
JPascal has quit []
robmiller has quit [Quit: Leaving.]
<johnjgrieco>
Any good advice for learning Ruby? Tools, Books, websites?
<ari-_-e>
dunno
<johnjgrieco>
How did you learn?
<ari-_-e>
reading other people's code is useful
<johnjgrieco>
Yeah, that is the route I'm currently taking
<johnjgrieco>
Well thanks again
<johnjgrieco>
time for me to hit the sack
Atttwww has quit [Ping timeout: 255 seconds]
johnjgrieco has quit [Quit: Page closed]
cored has joined #ruby-lang
cored has quit [Changing host]
cored has joined #ruby-lang
knu has joined #ruby-lang
benlovell has joined #ruby-lang
arBmind has joined #ruby-lang
thomasxie has quit [Quit: Leaving.]
danijoo has quit [Read error: Connection reset by peer]
frobrob has joined #ruby-lang
danijoo has joined #ruby-lang
ur5us has joined #ruby-lang
heftig has joined #ruby-lang
ironhide_604 has quit [Ping timeout: 245 seconds]
elia has joined #ruby-lang
cored has quit [Ping timeout: 252 seconds]
ur5us has quit [Read error: No route to host]
ur5us has joined #ruby-lang
ironhide_604 has joined #ruby-lang
lewix has joined #ruby-lang
JPascal has joined #ruby-lang
gregf_ has joined #ruby-lang
GBrawl has quit [Quit: Computer has gone to sleep.]
fezziwig has joined #ruby-lang
GBrawl_ has joined #ruby-lang
kitak_ has quit [Remote host closed the connection]
fezziwig has quit [Ping timeout: 276 seconds]
woollyams has joined #ruby-lang
kyb3r_ has quit [Read error: Connection reset by peer]
kitak_ has joined #ruby-lang
cbreeze has joined #ruby-lang
kitak_ has quit [Read error: Connection reset by peer]
kitak_ has joined #ruby-lang
lewix has quit [Remote host closed the connection]
toastynerd has joined #ruby-lang
lewix has joined #ruby-lang
GBrawl_ has quit [Quit: Computer has gone to sleep.]
mehlah has quit [Quit: Leaving...]
alex-quiterio1 has joined #ruby-lang
alex-quiterio1 has quit [Remote host closed the connection]
toastynerd has quit [Ping timeout: 240 seconds]
lewix has quit [Ping timeout: 240 seconds]
alex-quiterio has quit [Ping timeout: 258 seconds]
charliesome_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
cnivolle has quit [Remote host closed the connection]
franzip has joined #ruby-lang
stamina has joined #ruby-lang
yfeldblum has quit [Remote host closed the connection]
simono has joined #ruby-lang
elia has quit [Quit: (IRC Client: textualapp.com)]
elia has joined #ruby-lang
mehlah has joined #ruby-lang
bubodlack has joined #ruby-lang
elia has quit [Client Quit]
elia has joined #ruby-lang
kitak_ has quit [Remote host closed the connection]
elia has quit [Client Quit]
marr has quit [Ping timeout: 252 seconds]
twintail has quit [Quit: Leaving.]
joonty has joined #ruby-lang
rsl has joined #ruby-lang
lewix has joined #ruby-lang
ironhide_604 has quit [Ping timeout: 245 seconds]
alexju has joined #ruby-lang
ironhide_604 has joined #ruby-lang
lewix has quit [Ping timeout: 252 seconds]
roelof has joined #ruby-lang
<roelof>
Hello, You can use x.select { |y| y.even?} to make a new array with only even numbers
zenspider has quit [Ping timeout: 252 seconds]
qba73 has quit []
<roelof>
but how do I make it works as someone puts a y["a"'] as a argument. This gives a NoMethodError
zenspider has joined #ruby-lang
<roelof>
as test I made this : Test.assert_raise(NoMethodError , no_odds(["a"]), "Er bestaat geen ?even voor een string") but that will not work either
<yorickpeterse>
eh?
<yorickpeterse>
You mean something like x.select { |y| y['a'].even? }
<yorickpeterse>
+ ?
ht_ has joined #ruby-lang
<roelof>
yorickpeterse: nope, I mean something like this ["a".select { |y| y.iseven? }
<roelof>
or do I have to change my normal code with a if then ?
<sluukkonen>
probably something along those lines
<roelof>
sluukkonen: which lines ??
frzng has joined #ruby-lang
dmitrykorotkov has joined #ruby-lang
Kero has joined #ruby-lang
dmitrykorotkov is now known as Guest21294
priodev has quit [Ping timeout: 264 seconds]
ironhide_604 has quit [Remote host closed the connection]
ur5us has quit [Remote host closed the connection]
<roelof>
sluukkonen: do you mean the pastebin piece or the if-then ?
Guest21294 has quit [Ping timeout: 240 seconds]
<sluukkonen>
I mean the correct way to test it will be probably something like what you paste in that pastebin
bubodlack has quit [Read error: Connection reset by peer]
bubodlack has joined #ruby-lang
<sluukkonen>
but I don't know how that Test module you're using is built
marr has joined #ruby-lang
<roelof>
sluukkonen: pity . I tried this :http://pastebin.com/XsFXxxvu but then I see this error NoMethodError: undefined method `assert_raise' for Test:Class
bubodlack is now known as bubodlack|away
<badeball>
oh my gawd, mongoid really is rittled with method_missing overrides
<badeball>
and respond_to?
bubodlack|away is now known as bubodlack
<yorickpeterse>
badeball: yup
<yorickpeterse>
I've had cases where respond_to?() would return true
<yorickpeterse>
even if the method wasn't there
<badeball>
the stacktrace gives me absolutely no idea whats going on
<yorickpeterse>
Summary:
<yorickpeterse>
lol
<yorickpeterse>
Description:
<yorickpeterse>
lol error
<yorickpeterse>
^ hate those errors
<badeball>
in our case, because we have a translated app, but not bothered with translating mongoid.. Problem: translation missing: no.mongoid.errors.messages.document_not_found.message
<badeball>
I'm a big boy and probably would have understod ExceptionNotFound
<roelof>
sluukkonen: yorickpeterse thanks for all the help and have a good day
<roelof>
byee
<yorickpeterse>
roelof: toodles
<yorickpeterse>
badeball: the weirdest part is why you would want i18n translations
<yorickpeterse>
for errors
<yorickpeterse>
like
<yorickpeterse>
wat
roelof has quit [Quit: Page closed]
<badeball>
yeah, in no way do I want mongoid to handle that
sarkyniin has joined #ruby-lang
nofxx has quit [Ping timeout: 240 seconds]
nofxx has joined #ruby-lang
nofxx has quit [Changing host]
nofxx has joined #ruby-lang
skade_ has quit [Ping timeout: 276 seconds]
ozzloy has quit [Remote host closed the connection]
ozzloy has joined #ruby-lang
ozzloy has joined #ruby-lang
alexju has quit [Remote host closed the connection]
tomkadwill has quit [Remote host closed the connection]
tomkadwill has joined #ruby-lang
heftig has quit [Quit: Quitting]
alexju has joined #ruby-lang
postmodern has quit [Quit: Leaving]
frobrob has quit [Ping timeout: 252 seconds]
Derander has quit [Ping timeout: 276 seconds]
alexju has quit [Remote host closed the connection]
luiz_ has quit [Remote host closed the connection]
luiz_ has joined #ruby-lang
elia has joined #ruby-lang
toretore has joined #ruby-lang
tomkadwill has quit [Ping timeout: 240 seconds]
Derander has joined #ruby-lang
zz_nopc0de is now known as nopc0de
workmad3 is now known as wm3|away
vpretzel has joined #ruby-lang
<maloik>
day two of debugging invoicing totals in a rails 3.0 project without test coverage
<yorickpeterse>
write some tests you scrub
<maloik>
still haven't thrown myself off a cliff
<yorickpeterse>
oh wait TDD is dead anyway
* yorickpeterse
runs
<maloik>
easier said than done
<maloik>
I still haven't figured out the problem, while still working on a basic understanding of all these methods calculating a bunch of seemingly unrelated shit
<maloik>
some are cached, others aren't, some look like they'd be cached in the line item model but arent (all fields are nil)
<maloik>
good times
<apeiros>
yorickpeterse: given that he has no test, it's not TDD but BDTW anyway :)
<apeiros>
(Bug Driven Test Writing)
<maloik>
:D
<maloik>
that could definately be a thing
<maloik>
I think by the time I'm done it'll be DDI
<maloik>
development driven insanity
<apeiros>
I think insanity is pretty much a prerequisite for development
<certainty>
+1
<yorickpeterse>
well yeah
<maloik>
another problem (well, nuissance really) is that while testing the methods is all good and well, they actually have to be used in the pdf's for the invoices as well
skade_ has joined #ruby-lang
toastynerd has quit [Ping timeout: 258 seconds]
dvorak has quit [Quit: leaving]
dvorak has joined #ruby-lang
ascarter has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<yorickpeterse>
man updating shit to 2.1.2 is a game of whack-a-mole
<yorickpeterse>
but in a production environment
matp has joined #ruby-lang
<yorickpeterse>
Update Rails app X, now it fails at some random action_view require()
<yorickpeterse>
but only when you try to log in
sarkyniin has quit [Quit: Quitte]
<DefV>
hmz
<DefV>
wondering if maloik is working on a project I worked on before :-)
<yorickpeterse>
"oadError: cannot load such file -- action_view/template/error" <- out of fucking nowhere
<yorickpeterse>
* LoadError
JaRe_Ax has joined #ruby-lang
<maloik>
you're in the list of authors anyway :-)
<DefV>
maloik: that doesn't surprise me then :-)
<maloik>
I'm at the point where rewriting it for fun in my spare time almost sounds like a realistic option
<maloik>
:D
<DefV>
haha
<yorickpeterse>
oh derp, I think I forgot to deploy this app
<yorickpeterse>
so it's still running in 1.9 mode
<DefV>
just add tests while you go along
<yorickpeterse>
but trying to load 2.1 shit
<yorickpeterse>
brb, finding a nice wall to park my face in
JaReAx has quit [Ping timeout: 252 seconds]
JaRe_Ax is now known as JaReAx
<maloik>
yea that's the plan
bubodlack has quit [Read error: Connection reset by peer]
bubodlack has joined #ruby-lang
lcdhoffman has joined #ruby-lang
stamina has quit [Quit: WeeChat 0.4.3]
<yorickpeterse>
yay, everything except our dreaded REE app now runs on MRI 2.1
<yorickpeterse>
now to apply my GC hacks everywhere to get memory down
yalue has joined #ruby-lang
<yorickpeterse>
Death by a thousand yaks
<darix>
yorickpeterse: did you see the talk from the discourse dev about ruby 2.1 and memory?
<yorickpeterse>
I saw the blog post
<yorickpeterse>
I spent the past...3 weeks? Tweaking things
<yorickpeterse>
Rolled out 2.1.2 to a bunch of daemons last week
<yorickpeterse>
Started doing our Rails apps yesterday
<darix>
he mentioned that github has a 2.1 branch with GC improvements that are not upstream yet
yatish27 has quit [Remote host closed the connection]
yatish27 has joined #ruby-lang
toastynerd has joined #ruby-lang
stulzer has quit [Quit: leaving]
Sunnyan has joined #ruby-lang
yatish27 has quit [Remote host closed the connection]
nofxx__ has joined #ruby-lang
yatish27 has joined #ruby-lang
nofxx_ has quit [Ping timeout: 240 seconds]
toastynerd has quit [Ping timeout: 255 seconds]
lcdhoffman has quit [Quit: lcdhoffman]
yatish27 has quit [Remote host closed the connection]
lcdhoffman has joined #ruby-lang
ta has quit [Remote host closed the connection]
yatish27 has joined #ruby-lang
toastynerd has joined #ruby-lang
yatish27 has quit [Ping timeout: 264 seconds]
yatish27_ has joined #ruby-lang
elia has joined #ruby-lang
<musurgia>
I have a beginning question about file I/O if anyone is willing to help.
<darix>
musurgia: rule n
<darix>
musurgia: rule #1 just ask.
dik_dak has joined #ruby-lang
luiz_ has quit [Quit: Saindo]
bubodlack has joined #ruby-lang
mistym has joined #ruby-lang
<musurgia>
darix: thanks.
<musurgia>
Initialize method reads file into string as @@infile = File.open(@infile_name, "rb) ; @data = @@infile.read
elia has quit [Ping timeout: 258 seconds]
<musurgia>
I have a "main" method that closes the program based on user input; I use @@infile.close in that method.
<musurgia>
Question is, why does infile have to be a class variable?
yfeldblum has joined #ruby-lang
dik_dak has quit [Ping timeout: 240 seconds]
<ericwood>
musurgia: so it can be used across instances of that class?
mykoweb has joined #ruby-lang
<ericwood>
and they're all writing to the same file without stepping on each other's toes?
<ericwood>
makes sense to me
<musurgia>
Why doesn't it work as an instance variable?
mistym has quit [Remote host closed the connection]
<ericwood>
because an instance variable is only available inside a single instance
<ericwood>
say you have several instances of a class, all of which need to write to the same output file
<ericwood>
you could have each open the file for writing, but that doesn't work
<ericwood>
or you could have a single instance of the open file available to all instances so they can share it
<ericwood>
no more race conditions!
yatish27_ has quit [Remote host closed the connection]
yfeldblum has quit [Ping timeout: 265 seconds]
cored has joined #ruby-lang
cored has quit [Changing host]
cored has joined #ruby-lang
elia has joined #ruby-lang
<musurgia>
Okay, I'm close to understanding.
<workmad3>
ericwood: infile is a file being read from though, not written to ;)
<musurgia>
The string I read the file into is an instance variable, @data. I can use it in multiple methods of the class.
ta has joined #ruby-lang
<musurgia>
But I can't treat the input file the same way, it has to be @@infile.
<ericwood>
workmad3: I only skim things
philh_wfh has joined #ruby-lang
yatish27_ has joined #ruby-lang
<ericwood>
well, regardless my explanation still kind of makes sense
<workmad3>
ericwood: kinda... except that each new instance re-opens the file and then re-reads it into an instance variable :)
<ericwood>
workmad3: ideally it should check to ensure it points to something already
philh_wfh has left #ruby-lang [#ruby-lang]
<workmad3>
musurgia: I'm guessing that your 'main' method is a class method? if so, you need @@infile to be a class variable simply because you can't access instance variables from a class method (you don't have an instance to operate on)
<musurgia>
workmad3: Aha! That's the answer. Thank you.
<workmad3>
musurgia: so in essence, you're trying to make sure that you always close the file... but if you create > 1 instance of that class, you've abandoned an open file
<workmad3>
musurgia: really, what I suspect you want to do is simply '@data = File.read(@infile_name)'
toastynerd has quit [Remote host closed the connection]
sheperson has joined #ruby-lang
rsl has joined #ruby-lang
<workmad3>
musurgia: rather than open a file, call read on it and then only try to close it at the end of the program
<musurgia>
I don't need to open it explicitly? Am obviously new to ruby coming from C.
<workmad3>
musurgia: there are several ways to deal with files in ruby
<workmad3>
musurgia: and several convenience methods... such as File.read, which simply reads the entire file into memory
<workmad3>
musurgia: there's also File.readlines which gives you an array of lines
<workmad3>
musurgia: there's also a 'block-form' of File.open, which you could use, e.g. 'File.open(@infile_name, "rb") {|file| @data = file.read}'
<workmad3>
musurgia: all of those will open the file, read the data and then close the file again, rather than leaving it open to be cleaned up (or not) later
dik_dak has joined #ruby-lang
<workmad3>
musurgia: you tend to only need to keep a file object around if you need to deal with it over a longer period of time in ruby... such as ericwood's example where you open a file for writing to and keep that reference around :)
<musurgia>
workmad3: Very helpful, thanks. Makes sense that if you're just reading contents of file once it would close immediately after.
elia has quit [Quit: Computer has gone to sleep.]
<musurgia>
PS, is a "main" class method (obvious holdover from C thinking) a good idea?
jsullivandigs has joined #ruby-lang
nofxx__ has quit [Ping timeout: 252 seconds]
WishBoy has joined #ruby-lang
elia has joined #ruby-lang
yalue has quit [Quit: Leaving]
nofxx__ has joined #ruby-lang
chouhoulis has joined #ruby-lang
mistym has joined #ruby-lang
chouhoulis has quit [Remote host closed the connection]
<workmad3>
musurgia: the two approaches I've tended to see in ruby are either scripts, where the code is just written at the top-level and run from top-to-bottom, or larger applications which tend to have an 'Application' object of some form... in the latter case, it seems somewhat common to have a 'run' or a 'start' method on that object to enter the main program flow after you've finished loading code and config
chouhoulis has joined #ruby-lang
khaase has quit [Remote host closed the connection]
khaase has joined #ruby-lang
yalue has joined #ruby-lang
<musurgia>
workmad3: Okay, thanks. I need to read more real code instead of just trying to figure out from the textbooks.
zlogan has quit [Ping timeout: 276 seconds]
<workmad3>
musurgia: ruby is a somewhat different world from C... the idea of a 'main' method as the entry point into a program doesn't really translate well... in C, you need that in order to create the compiled binary... in ruby, when you invoke ruby, it just starts running code from the start of the file you specify (e.g. ruby foobar.rb just starts running from the top of foobar.rb)
khaase has quit [Ping timeout: 245 seconds]
ghg has joined #ruby-lang
<workmad3>
musurgia: so in the one sense, no, the idea of a 'main' method doesn't make sense... but if you have a large application, it makes sense to have an object wrapping that top-level abstraction up, and then a single method to 'start' it makes sense... similarly, when you have larger command line tools, it's common to have small scripts in a bin/ directory that load stuff and pass command line options through to some form of
havenwood has joined #ruby-lang
symm- has quit [Ping timeout: 240 seconds]
lcdhoffman has quit [Quit: lcdhoffman]
joonty has quit [Ping timeout: 255 seconds]
<musurgia>
workmad3: to some form of ...? (msg cut off )
<workmad3>
application object and then just call a method on it
<workmad3>
sorry, for some reason my irc client doesn't show me when my messages truncate :(
solars has quit [Ping timeout: 252 seconds]
<musurgia>
This program is about 90 lines. I thought it good to put all the code into one class,
<musurgia>
then at the bottom of the file I just call game = Game.new("input.file") ; Game.main(game)
<musurgia>
But perhaps in a short program I could just as easily put the "main" routine at the bottom on its own.
sheperson has quit [Quit: sheperson]
|jemc| has joined #ruby-lang
frzng has quit [Quit: frzng]
nathanstitt has joined #ruby-lang
joonty has joined #ruby-lang
sheperson has joined #ruby-lang
herpless has joined #ruby-lang
fezziwig has quit [Remote host closed the connection]
bubodlac has joined #ruby-lang
bubodlack has quit [Read error: Connection reset by peer]
ta has quit [Ping timeout: 264 seconds]
toastynerd has joined #ruby-lang
yfeldblum has joined #ruby-lang
lolmaus has quit [Read error: Connection reset by peer]
khaase has joined #ruby-lang
khaase has joined #ruby-lang
khaase has quit [Changing host]
speakingcode-wor has quit [Quit: Lost terminal]
yfeldblum has quit [Ping timeout: 264 seconds]
yatish27_ has quit [Remote host closed the connection]
yatish27 has joined #ruby-lang
sheperson has quit [Ping timeout: 258 seconds]
Sunnyan has quit [Ping timeout: 240 seconds]
lolmaus has joined #ruby-lang
yatish27 has quit [Ping timeout: 255 seconds]
diegoviola has quit [Quit: WeeChat 0.4.3]
ta has joined #ruby-lang
arooni-mobile has joined #ruby-lang
rippa has joined #ruby-lang
herpless has quit []
Atttwww has joined #ruby-lang
sheperson has joined #ruby-lang
robbyoconnor has quit [Excess Flood]
robbyoconnor has joined #ruby-lang
sheperson_ has joined #ruby-lang
sheperson has quit [Ping timeout: 240 seconds]
ta has quit [Remote host closed the connection]
sheperson_ is now known as sheperson
vpretzel is now known as vpretzel|away
diegoviola has joined #ruby-lang
mister_integer has joined #ruby-lang
mister_integer has quit [Remote host closed the connection]
mister_integer has joined #ruby-lang
wallerdev has joined #ruby-lang
frzng has joined #ruby-lang
havenwood has quit [Remote host closed the connection]
Cakey has joined #ruby-lang
sharpmachine has joined #ruby-lang
x0f_ has joined #ruby-lang
x0f has quit [Ping timeout: 245 seconds]
jayne has quit [Read error: Connection reset by peer]
tbuehlmann has quit [Quit: Leaving]
snsei has quit [Remote host closed the connection]
__butch__ has joined #ruby-lang
jxpx777 has joined #ruby-lang
lcdhoffman has joined #ruby-lang
mistym has quit [Remote host closed the connection]
vpretzel_ has joined #ruby-lang
vpretzel|away has quit [Ping timeout: 255 seconds]
havenwood has joined #ruby-lang
hahuang65 has quit [Ping timeout: 252 seconds]
psycho_one has joined #ruby-lang
<musurgia>
I'm using String.scan(@regex) to extract words in brackets from string and store them in array.
<musurgia>
But if there are multiple words inside the brackets, then that gets stored as an array and I end up with an array of arrays.
<musurgia>
Can I just scan them as plain strings regardless of the contents inside the brackets?
iamcalledrob has joined #ruby-lang
<musurgia>
to be clear, I mean @array = @string.scan(@regex)
yatish27 has joined #ruby-lang
<bougyman>
musurgia: can you show example text and expected results?
<musurgia>
bougyman: Like a madlib. "A {person's name} {verb}ed into a {place}"
<musurgia>
current results: @array = [["person's name"], ["verb"], ["place"]]
phansch has quit [Ping timeout: 258 seconds]
lewix has joined #ruby-lang
lewix has quit [Changing host]
lewix has joined #ruby-lang
<apeiros>
musurgia: doesn't seem to be related to having multiple words…
<apeiros>
musurgia: anyway, you use a capturing group in your scan, that's why
<bougyman>
s.scan(/\{(.*?)\}/).flatten
<apeiros>
using flatten is admitting defeat.
lewis has quit [Ping timeout: 255 seconds]
<apeiros>
at least in this context it doesn't matter that you didn't use flatten(1) :-p
AncientAmateur has quit [Remote host closed the connection]
mikecmpbll has quit [Quit: i've nodded off.]
<musurgia>
apeiros: can you explain for this noob?
<apeiros>
musurgia: () in a regex is a capturing group. if you have one or more capturing groups, scan will return an array of arrays. an array for every match, with the values of the capturing groups.
<apeiros>
ri String#scan documents that btw.
<apeiros>
so if you don't want arrays of arrays as result, you can either use flatten, as bougyman suggested, or not use a capturing group in your regex
elia has quit [Quit: Computer has gone to sleep.]
cored has quit [Ping timeout: 252 seconds]
<musurgia>
apeiros, bougyman: thanks. Will read docs on flatten and scan!
fezziwig has joined #ruby-lang
bubodlac has quit [Read error: Connection reset by peer]
mehlah has quit [Quit: Leaving...]
<apeiros>
musurgia: oh, btw, [] are brackets. {} are curly braces
<apeiros>
>> "A {person's name} {verb}ed into a {place}".scan(/(?<=\{)[^}]*(?=\})/)
cnivolle has quit [Remote host closed the connection]
cnivolle has joined #ruby-lang
havenwood has quit [Remote host closed the connection]
havenwood has joined #ruby-lang
cnivolle has quit [Ping timeout: 265 seconds]
yatish27 has joined #ruby-lang
fijimunkii has joined #ruby-lang
havenwood has quit [Remote host closed the connection]
simono has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
yfeldblum has joined #ruby-lang
gix has quit [Ping timeout: 276 seconds]
cored has joined #ruby-lang
gix has joined #ruby-lang
AncientAmateur has quit [Read error: Connection reset by peer]
AncientAmateur has joined #ruby-lang
sharpmachine has quit [Remote host closed the connection]
mykoweb has joined #ruby-lang
vpretzel is now known as vpretzel|sysadmi
jayne has joined #ruby-lang
JohnBat26 has joined #ruby-lang
sharpmachine has joined #ruby-lang
lewix has quit [Quit: Leaving]
lewix has joined #ruby-lang
lewix has joined #ruby-lang
lewix has quit [Changing host]
sheperson has quit [Ping timeout: 258 seconds]
simono has joined #ruby-lang
mikewintermute has joined #ruby-lang
sheperson has joined #ruby-lang
Sunnyan has quit [Ping timeout: 240 seconds]
mikewintermute has quit [Remote host closed the connection]
mikewintermute has joined #ruby-lang
jhass|off is now known as jhass
scampbell has quit [Remote host closed the connection]
mikewintermute has left #ruby-lang [#ruby-lang]
fragamus has quit [Quit: Computer has gone to sleep.]
frzng has quit [Quit: frzng]
arooni-mobile__ has joined #ruby-lang
chouhoul_ has joined #ruby-lang
arooni-mobile has quit [Ping timeout: 255 seconds]
robmiller has joined #ruby-lang
chouhoul_ has quit [Remote host closed the connection]
chouhoul_ has joined #ruby-lang
chouhoulis has quit [Ping timeout: 255 seconds]
mykoweb has quit [Remote host closed the connection]
mykoweb has joined #ruby-lang
moogumbo has joined #ruby-lang
mykoweb has quit [Ping timeout: 240 seconds]
BucOder has joined #ruby-lang
yatish27 has quit [Remote host closed the connection]
siflyn has joined #ruby-lang
luiz_lha has quit [Remote host closed the connection]
luiz_lha has joined #ruby-lang
mister_i_ has joined #ruby-lang
mykoweb has joined #ruby-lang
enebo has joined #ruby-lang
matp has quit [Quit: Bye!]
mister_integer has quit [Ping timeout: 252 seconds]
amsi has joined #ruby-lang
Fushi has quit [Quit: Connection closed for inactivity]
symm- has joined #ruby-lang
zlogan has joined #ruby-lang
datazombie has joined #ruby-lang
<datazombie>
hello, I have a dataset of numbers and I want to create a policy in which if i have 311, 312, 313, 316 i want to be able to say all this fall under 31x
<datazombie>
without specifying the 31x category
Asher has joined #ruby-lang
<Mon_Ouie>
I don't know what you mean by a "policy" but that sounds like dividing by 10
robmiller has quit [Quit: Leaving.]
zlogan has quit [Ping timeout: 255 seconds]
<datazombie>
a policy in my mind is a validation rule
<apeiros>
if your question requires reading your mind, it can't be answered.
<apeiros>
(haven't actually seen a question yet, so well, waiting)
<wallerdev>
lol
<datazombie>
ill repost the question
<datazombie>
I have a dataset of numbers and I want to create a policy in which if i have 311, 312, 313, 316 i want to be able to say all this fall under 31x
<jhass>
may I also copy paste apeiros answers?
Coincidental has quit [Read error: Connection reset by peer]
<apeiros>
I'm sorry, but I still don't see a question
<wallerdev>
>> list = [311, 312, 313, 316]; if list == [311, 312, 313, 316]; "this fall under 31x"; end