micalexander has quit [Remote host closed the connection]
micalexander has joined #ruby-lang
Cakey has quit [Ping timeout: 240 seconds]
yubrew has quit [Ping timeout: 264 seconds]
bantic has joined #ruby-lang
yfeldblum has quit [Quit: Leaving...]
NemesisD has left #ruby-lang ["WeeChat 0.4.3"]
yfeldblum has joined #ruby-lang
micalexander has quit [Ping timeout: 264 seconds]
|jemc| has joined #ruby-lang
_djbkd has quit [Remote host closed the connection]
djbkd has joined #ruby-lang
lewix has joined #ruby-lang
lewix has joined #ruby-lang
nathanstitt has joined #ruby-lang
chouhoulis has joined #ruby-lang
jfarmer has quit [Quit: Computer has gone to sleep.]
toastynerd has quit [Remote host closed the connection]
cstrahan has joined #ruby-lang
chouhoulis has quit [Remote host closed the connection]
jfarmer has joined #ruby-lang
nathanstitt has quit [Quit: I growing sleepy]
ddv has quit [Ping timeout: 245 seconds]
alexju has joined #ruby-lang
nathanstitt has joined #ruby-lang
ddv has joined #ruby-lang
benlovell has quit [Ping timeout: 244 seconds]
benlovell has joined #ruby-lang
lewix has quit [Ping timeout: 245 seconds]
bantic has quit [Quit: bantic]
skade has quit [Quit: Computer has gone to sleep.]
<zenspider>
anyone currently having problems with rubygems installs atm?
<zenspider>
did the API and/or DNS services for rubygems just go down? I'm hanging installs on the call to v1/dependencies but --debug hints it might be timeouts on dns
spastorino has quit [Quit: Connection closed for inactivity]
sepp2k1 has quit [Read error: Connection reset by peer]
benlovell has quit [Ping timeout: 244 seconds]
t_3212 has quit [Ping timeout: 264 seconds]
benlovell has joined #ruby-lang
Averna has joined #ruby-lang
stardiviner has joined #ruby-lang
lewix has joined #ruby-lang
cored has joined #ruby-lang
cored has joined #ruby-lang
cored has quit [Changing host]
CaptainJet has quit [Ping timeout: 255 seconds]
pixelhandler has quit [Quit: pixelhandler]
marr has quit [Ping timeout: 240 seconds]
shinnya has quit [Ping timeout: 244 seconds]
mistym has quit [Remote host closed the connection]
CodeBunny has quit [Ping timeout: 245 seconds]
diegoviola has joined #ruby-lang
yubrew has joined #ruby-lang
jsullivandigs has quit [Remote host closed the connection]
<yorickpeterse>
So if you use a splat, make sure you pass in arguments separately
dsaint-pierre has quit [Ping timeout: 245 seconds]
<roelof>
yorickpeterse: and that what I struggeling with
<yorickpeterse>
What exactly?
knu has joined #ruby-lang
<matti>
Splat all the things.
* matti
splats yorickpeterse
<yorickpeterse>
[]
<roelof>
I have to calculate the costs of a order which is a splat . and the costs are this : if the order is {:rice => 1, :noodles => 1}, and the menu is {:rice => 3, :noodles => 2}, then the cost is 5.
<roelof>
and there can be more then 1 order
<yorickpeterse>
roelof: could you pastie a simple example?
<roelof>
pff. then I have to make one up
<yorickpeterse>
well right now your case doesn't make much sense
<roelof>
oke, lets says this. I still have to calculate the costs of a order and the order exist of this [rice, noodles, rice]
<roelof>
yorickpeterse: it's a exercise of ruby monkey
<yorickpeterse>
I have no idea what ruby monkey is
<roelof>
yorickpeterse: a site where you can learn ruby by doing exercises
<maloik>
gist the exercise?
<maloik>
I'm not exactly following either
<maloik>
(not that I read all of the previous conversation)
<roelof>
yorickpeterse: thanks for pointing me at the right path
<yorickpeterse>
np
dm78 has joined #ruby-lang
skade has quit [Quit: Computer has gone to sleep.]
yubrew has joined #ruby-lang
skammer has joined #ruby-lang
rahul_j has quit [Quit: rahul_j]
rahul_j has joined #ruby-lang
yfeldblum has quit [Remote host closed the connection]
dm78 has quit [Ping timeout: 244 seconds]
Cakey has joined #ruby-lang
yubrew has quit [Ping timeout: 264 seconds]
jgpawletko has quit [Quit: jgpawletko]
jgpawletko has joined #ruby-lang
jgpawletko has quit [Client Quit]
majjoha has quit [Ping timeout: 272 seconds]
rahul_j has quit [Ping timeout: 240 seconds]
rahul_j has joined #ruby-lang
elia has joined #ruby-lang
roelof has quit [Quit: Page closed]
skade has joined #ruby-lang
elia has quit [Quit: Computer has gone to sleep.]
ascarter has joined #ruby-lang
havenwood has joined #ruby-lang
elia has joined #ruby-lang
havenwood has quit [Ping timeout: 264 seconds]
<solars>
hey, how can I write something like this: arr.push mymethod rescue ''?
yfeldblum has joined #ruby-lang
<solars>
it won't work as push is not called here, but I cannot put the rescue in brackets it seems
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Lumio has joined #ruby-lang
yfeldblu_ has joined #ruby-lang
<yorickpeterse>
solars: what exactly are you trying to rescue?
<yorickpeterse>
Also, it's better to check beforehand if you can push in the first place, instead of just swallowing the error
dsaint-pierre has joined #ruby-lang
<solars>
yorickpeterse, it's just a quick little script, an exception can occur inside the method called, and in that case I'd like to just push '' or nil
yfeldblum has quit [Ping timeout: 240 seconds]
<yorickpeterse>
arr.push(X) rescue arr.push(nil)
<solars>
ok that was obvious :) haha
<solars>
thanks
yfeldblu_ has quit [Ping timeout: 244 seconds]
jgpawletko has joined #ruby-lang
dsaint-pierre has quit [Ping timeout: 244 seconds]
allomov has quit [Remote host closed the connection]
relix has joined #ruby-lang
yubrew has joined #ruby-lang
tkuchiki_ has joined #ruby-lang
diegoviola has joined #ruby-lang
egrep has joined #ruby-lang
<egrep>
Anybody have any idea why ruby gives me this error? `require': cannot load such file -- OpenSSL (LoadError)
allomov has joined #ruby-lang
<apeiros>
because it can't load a file named 'OpenSSL'. you probably want openssl instead.
<egrep>
Yes indeed I do. ._. I can be stupid sometimes.
<egrep>
Thanks, apeiros.
egrep has left #ruby-lang ["adios, with gratitudes"]
tkuchiki has quit [Ping timeout: 240 seconds]
yubrew has quit [Ping timeout: 244 seconds]
tkuchiki_ has quit [Ping timeout: 245 seconds]
dm78 has joined #ruby-lang
diegovio1 has joined #ruby-lang
diegoviola is now known as Guest32933
diegovio1 is now known as diegoviola
Guest32933 has quit [Ping timeout: 272 seconds]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
fjfish has quit [Remote host closed the connection]
dm78 has quit [Ping timeout: 264 seconds]
Cakey has quit [Ping timeout: 245 seconds]
relix has joined #ruby-lang
jeffs_ has joined #ruby-lang
francisfish has joined #ruby-lang
skam_ has joined #ruby-lang
lolmaus has quit [Ping timeout: 245 seconds]
cnivolle_ has quit [Ping timeout: 260 seconds]
lolmaus has joined #ruby-lang
lewix has joined #ruby-lang
lewix has quit [Changing host]
lewix has joined #ruby-lang
cnivolle has joined #ruby-lang
tkuchiki has joined #ruby-lang
skam_ has quit [Ping timeout: 246 seconds]
francisfish has quit [Remote host closed the connection]
allomov has quit [Remote host closed the connection]
allomov has joined #ruby-lang
stamina has joined #ruby-lang
elia has quit [Quit: Computer has gone to sleep.]
dwknoxy has joined #ruby-lang
elia has joined #ruby-lang
yfeldblum has joined #ruby-lang
lewix has quit [Ping timeout: 244 seconds]
dvorak has quit [Quit: leaving]
yfeldblum has quit [Ping timeout: 240 seconds]
Blaguvest has joined #ruby-lang
dvorak has joined #ruby-lang
vpretzel_ has quit [Remote host closed the connection]
centrx has joined #ruby-lang
dsaint-pierre has joined #ruby-lang
vpretzel has joined #ruby-lang
dsaint-pierre has quit [Remote host closed the connection]
dsaint-pierre has joined #ruby-lang
GBrawl has joined #ruby-lang
cnivolle_ has joined #ruby-lang
diegoviola has quit [Remote host closed the connection]
lewix has joined #ruby-lang
cnivolle has quit [Ping timeout: 245 seconds]
lewix has quit [Client Quit]
diegoviola has joined #ruby-lang
ascarter has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
malconis has joined #ruby-lang
_zeedaniel has joined #ruby-lang
<_zeedaniel>
hey hey!
<centrx>
Ahoy
<_zeedaniel>
how's it going?
<centrx>
Rubytastic
<apeiros>
swell
<_zeedaniel>
nice!
<_zeedaniel>
I love Rubytastic days.
<_zeedaniel>
I'm working on a job queue system and decided to use Resque, but in order for us to be able to queue up jobs from several different applications, I wrote a basic app that just wraps Resque and offers an API with a couple of end-points.
<centrx>
Impressive
<_zeedaniel>
The fun part though is the gem I'm working on now, which is a light-weight DSL for creating workers.
<_zeedaniel>
So, basically I want to be able to have a bunch of *.do files in a /workers/ directory.
<_zeedaniel>
and then this gem parses them, creates the end points on the API AND creates a basic class with the appropiate methods for resque to use.
<_zeedaniel>
I'm having fun with class_exec right now so the DB is available to the code in the blocks.
cnivolle has joined #ruby-lang
<_zeedaniel>
It was driving me a little batty earlier, but I got it sorted out.
<apeiros>
nice seeing a happy person for a change :D
<_zeedaniel>
:-)
<_zeedaniel>
happy is good
<_zeedaniel>
in fact...
<_zeedaniel>
Rubytastic!
<_zeedaniel>
is best
dm78 has joined #ruby-lang
<_zeedaniel>
so, i'm curious, i need some input from y'all
<_zeedaniel>
variable assignment from if/case/etc
<_zeedaniel>
my co-worker and i were arguing about this a couple weeks ago
cnivolle_ has quit [Ping timeout: 240 seconds]
<_zeedaniel>
he thinks that assigning variables from if/case/etc and indenting the code becuase of the var name being at the left-most position makes it unreadable and he just hates it. i LOVE it
[spoiler] has quit [Remote host closed the connection]
<_zeedaniel>
i love being able write a variable name once and know that whatever returns from the conditional or case statement or whatever, is going INTO that var.
charliesome has joined #ruby-lang
<_zeedaniel>
does anyone else have an opinion on this?
<workmad3>
_zeedaniel: I don't like using if/then/else like that... I'd prefer to use a ternary for assignment
<ddfreyne>
_zeedaniel: Can you give an example of the two styles?
<workmad3>
_zeedaniel: I find if it would be readable with a 'some_var = if foobar;...' then it's more readable with a ternary ;)
dm78 has quit [Ping timeout: 244 seconds]
nathanstitt has joined #ruby-lang
<_zeedaniel>
well, if there's only an if and else, then ternary is fine. but in some cases there are more cases than that. which is moreso what i'm referring to
<workmad3>
_zeedaniel: if there's more than that in the conditional, I don't find assigning from it appropriate, personally
<workmad3>
_zeedaniel: and for the case statement, I just added a comment with my preference ;)
<_zeedaniel>
bleh, okay
<_zeedaniel>
:-)
<ddfreyne>
_zeedaniel: I do not like the indent. It messes with the general program structure, and thus makes it hard to analyse the high-level view of the program.
<ddfreyne>
(my two cents)
<_zeedaniel>
that's really what his issue is too. he doesn't like the indent
<_zeedaniel>
i can understand that too
<workmad3>
_zeedaniel: end of the day though, what's most important with code style isn't selecting a 'perfect' one, it's *having* one and being consistent with it
<_zeedaniel>
but, workmad3: in your example, you don't even need to set language since it's local anyhow and not used again, so you're in accomplishing the same thing as mine, but no indent since it's in the separate method :-)
<_zeedaniel>
true
<workmad3>
_zeedaniel: I just removed the setting from the method
<_zeedaniel>
:-)
<ddfreyne>
+1 for consistency
<workmad3>
_zeedaniel: and it's not the same because it doesn't have weird indentation and separates the case from the indent ;)
<_zeedaniel>
haha
<ddfreyne>
I have changed my coding style to be more consistent with other people's style. I don't regret it.
<_zeedaniel>
ya
<workmad3>
_zeedaniel: your co-worker's preference also achieves the same result ;)
<_zeedaniel>
that's what i think i've done most, when you work someplace, you need to make sure everyone else can vibe with the style, so it's just about being consistent
<workmad3>
_zeedaniel: achieving the same result is, after all, the point of different styles of doing the same thing... :P
arBmind has quit [Quit: Leaving.]
<_zeedaniel>
inddeed :-)
<workmad3>
(sorry, just found it kinda amusing that you picked up 'it doesn the same thing' as a 'do it my way' argument in a style discussion ;) )
<workmad3>
*does
<_zeedaniel>
lol
<_zeedaniel>
i'm flexible when it comes to the coding style, unless it's bad code :-)
<_zeedaniel>
then i'll put my foot down, *bizaam*
<_zeedaniel>
okay, time to make some more binary donuts :-)
<_zeedaniel>
bbl
kek_ has joined #ruby-lang
kek_ has quit [Read error: Connection reset by peer]
momomomomo has joined #ruby-lang
kek_ has joined #ruby-lang
pglombardo has joined #ruby-lang
kek has quit [Ping timeout: 264 seconds]
spastorino has joined #ruby-lang
karamazov has joined #ruby-lang
GBrawl has quit [Quit: Computer has gone to sleep.]
bantic has joined #ruby-lang
enebo has joined #ruby-lang
ari-_-e has quit [Ping timeout: 255 seconds]
yfeldblum has joined #ruby-lang
diegoviola has quit [Ping timeout: 264 seconds]
yubrew has joined #ruby-lang
chouhoulis has joined #ruby-lang
havenwood has joined #ruby-lang
vpretzel_ has joined #ruby-lang
yfeldblum has quit [Ping timeout: 244 seconds]
Squarepy has joined #ruby-lang
Squarepy has quit [Changing host]
Squarepy has joined #ruby-lang
ascarter has joined #ruby-lang
Squarepy has quit [Remote host closed the connection]
Squarepy has joined #ruby-lang
Squarepy has quit [Remote host closed the connection]
diegoviola has joined #ruby-lang
alexju has joined #ruby-lang
loincloth has joined #ruby-lang
Squarepy has joined #ruby-lang
vpretzel has quit [Ping timeout: 244 seconds]
mndoci has joined #ruby-lang
luiz_lha has joined #ruby-lang
skade has quit [Ping timeout: 245 seconds]
tbuehlmann has joined #ruby-lang
skade has joined #ruby-lang
AncientAmateur has joined #ruby-lang
karamazo_ has joined #ruby-lang
mndoci has quit [Remote host closed the connection]
cnivolle_ has joined #ruby-lang
mndoci has joined #ruby-lang
ari-_-e has joined #ruby-lang
ascarter has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
karamazov has quit [Ping timeout: 240 seconds]
jhass is now known as jhass|off
cnivolle has quit [Ping timeout: 240 seconds]
karamazo_ is now known as karamazov
mndoci has quit [Ping timeout: 244 seconds]
kfpratt has joined #ruby-lang
stardiviner has joined #ruby-lang
momomomomo has quit [Quit: momomomomo]
ironhide_604 has joined #ruby-lang
momomomomo has joined #ruby-lang
mikecmpbll has quit [Ping timeout: 240 seconds]
mikecmpbll has joined #ruby-lang
diegoviola has quit [Quit: WeeChat 0.4.3]
dm78 has joined #ruby-lang
centrx has quit [Quit: Mission accomplished. Ready for self-termination.]
symm- has quit [Ping timeout: 240 seconds]
karamazov has quit [Read error: Connection reset by peer]
karamazov has joined #ruby-lang
mikecmpbll has quit [Quit: i've nodded off.]
dachi has quit [Quit: ...]
karamazo_ has joined #ruby-lang
mikecmpbll has joined #ruby-lang
<maloik>
now i want a donut
GBrawl has joined #ruby-lang
karamazov has quit [Ping timeout: 240 seconds]
dwayhs has joined #ruby-lang
GBrawl_ has joined #ruby-lang
<matti>
Me too me too
GBrawl has quit [Ping timeout: 240 seconds]
kfpratt has quit [Remote host closed the connection]
apt-get_ has joined #ruby-lang
miqui_ has joined #ruby-lang
karamazo_ has quit [Read error: Connection reset by peer]
karamazov has joined #ruby-lang
miqui has quit [Ping timeout: 240 seconds]
ascarter has joined #ruby-lang
sarkyniin has quit [Ping timeout: 245 seconds]
kwd has quit [Quit: kwd]
karamazo_ has joined #ruby-lang
bjh13 has joined #ruby-lang
karamazov has quit [Read error: Connection reset by peer]
dik_dak has joined #ruby-lang
mistym has joined #ruby-lang
jsullivandigs has joined #ruby-lang
kek_ has quit [Remote host closed the connection]
mistym has quit [Remote host closed the connection]
AKASkip has quit [Ping timeout: 240 seconds]
shinnya has joined #ruby-lang
miqui_ is now known as miqui
ascarter has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<roelof>
with orders = {:rice => 1, :noodles => 1} and menu = {:rice => 3, :noodles => 2}
MikaAK1 has joined #ruby-lang
<roelof>
why when I do Restaurant.cost(*orders) I see this error : undefined method `cost' for Restaurant:Class (NoMethodError)
Mon_Ouie has joined #ruby-lang
Mon_Ouie has joined #ruby-lang
MikaAK1 has quit [Client Quit]
<jhass>
because cost is an instance method, not a class method
<havenwood>
roelof: You have to instantiate the class to get access to its instance methods.
<roelof>
oke, so I have to do Restaurant.new.costs
<havenwood>
instantiate an instance of the class*
<roelof>
also not
<roelof>
ruby can be confusing
<jhass>
what error message do you get now?
djbkd has joined #ruby-lang
rahul_j has quit [Quit: rahul_j]
<roelof>
wrong number of arguments (0 for 1) (ArgumentError)
<havenwood>
roelof: initialize(menu)
<jhass>
and if you actually read it, what do you think it means?
<roelof>
and with Restaurant.new(menu).costs I get a answer 0
<yorickpeterse>
whitequark: the somewhat typical scandinavian stuff
<jhass>
roelof: yeah sure, without orders you don't have to pay anything
<bougyman>
.22
AncientAmateur has joined #ruby-lang
|jemc| has quit [Quit: WeeChat 0.4.3]
<roelof>
jhass oke, with Restaurant.new(menu).cost(orders) I see that with @menu.keys I can find the keys of the menu
<roelof>
now find a way I can compare order[0] with a menu,key so I can find the costs
|jemc| has joined #ruby-lang
momomomomo has joined #ruby-lang
<jhass>
roelof: make sure to paste the whole program when you're done so we can maybe give you some tips ;)
marr has quit [Ping timeout: 272 seconds]
<roelof>
I have now this : http://pastebin.com/DEEMe2Ha and see this error: undefined method `key' for {:rice=>3, :noodles=>2}:Hash (NoMethodError)
<whitequark>
yorickpeterse: yes, I mean, is there any other kind?
<jhass>
roelof: yes, there's no key method on Hash
<jhass>
what would you expect it to do?
<roelof>
that it would look for the name of the order so rice or noodles on the order and look for the price in the menu hash
melter_ has joined #ruby-lang
<roelof>
and count them all up
MikaAK has quit [Ping timeout: 264 seconds]
djbkd has quit [Quit: My people need me...]
djbkd has joined #ruby-lang
<jhass>
but how would that work? it would magically read the value of the right hand side and store that somewhere internally so the next access to the hash would magically return the value?
<roelof>
frustating : when I do this : costs = costs + @menu[order] * order[0] I see this error : undefined method `*' for nil:NilClass (NoMethodError)
|jemc| has quit [Quit: WeeChat 0.4.3]
<jhass>
that means there's no order key in @menu
<jhass>
roelof: use p to assert that the variables contain what you think they do
<roelof>
jhass : order[0] contains the name. So that one I have to look up in menu and then find the value
<jhass>
then do that
<jhass>
@menu[order[0]]
<roelof>
:in `+': nil can't be coerced into Fixnum (TypeError)
<jhass>
so order[1] returns nil
<jhass>
back to using p to check it's what you think it is
mehlah has quit [Quit: Leaving...]
Johz has joined #ruby-lang
<roelof>
order is a hash
<roelof>
and order.keys gives both entries :(
<roelof>
I need only 1
GBrawl has joined #ruby-lang
<jhass>
how about iterating over the hash?
GBrawl has quit [Client Quit]
<roelof>
chips I do that I do orders.each
<jhass>
didn't you just find out that yields you a hash in order?
yfeldblum has joined #ruby-lang
dsaint-pierre has quit [Ping timeout: 245 seconds]
<jhass>
so apparently orders is not what you think it is
cored has joined #ruby-lang
cored has quit [Changing host]
cored has joined #ruby-lang
karamazo_ has joined #ruby-lang
<roelof>
wierd. when I do order.is_a? Hash I see true. When I do puts "Order 1 has this key #{order.keys}" I see this output: Order 1 has this key ricenoodles
<roelof>
Apperantly I do not seem to now how I can get the key of only one entries
<roelof>
Apperantly I do not seem to now how I can get the key of only one entrie
<jhass>
you would iterate over the hash
diegoviola has quit [Ping timeout: 245 seconds]
karamazov has quit [Ping timeout: 264 seconds]
spastorino has quit [Quit: Connection closed for inactivity]
diegoviola has joined #ruby-lang
<roelof>
oke, so also iterate over order where I also iterate over *orders ???
<jhass>
what do you think *orders in a method definition does
<jhass>
?
<roelof>
that contains all orders
<roelof>
where order schould contain only 1 order
djbkd has quit [Remote host closed the connection]
<jhass>
that's what you think the result is, but answer my question, what is the difference between def foo(orders) and def foo(*orders)
rippa has joined #ruby-lang
djbkd has joined #ruby-lang
lolmaus has quit [Read error: Connection reset by peer]
<roelof>
def foo(orders) orders has only 1 value so one order
Neurexin has joined #ruby-lang
<roelof>
def foo(*orders) orders has more then 1 value
<roelof>
I think I will hit the books again about hashes
<roelof>
and arrays. This exercise confuse me a lot
djbkd has quit [Remote host closed the connection]
<roelof>
as far as I understand it *orders is appearently a array containing all the orders.
spastorino has joined #ruby-lang
<roelof>
So when I iterate over it with orders.each do |order| the order varaible contains only 1 order which contains two thing rice and the amount and noodles and the amount
djbkd has joined #ruby-lang
<jhass>
you're still thinking about this wrong
<jhass>
def foo(*orders) is to tell ruby to _do_ something
diegoviola has quit [Read error: Connection reset by peer]
<jhass>
similar foo(*orders) (when calling a method) is to tell ruby to _do_ something. It's not the same as in the method definition though
<jhass>
that _do_ is "collect all remaining arguments in an array" in the first case and "treat this as an array and pass the elements as individual arguments" in the second
cored_ has joined #ruby-lang
<roelof>
yep, put all the orders in a variable called orders which contains all the orders so for example : {:rice => 1, :noodles => 1}
sdouglas_ has quit [Remote host closed the connection]