<grahamb>
I'm going through combinators.info and have gotten stuck about 1/3 way in. It was totally clear until `yield` was used. Can anyone help me understand? Many thanks. http://pastebin.com/w0Rh1ycM
<grahamb>
dminuoso: right, that one was totally clear.
orangey has joined #ruby
<grahamb>
so the block, is that sort of just taking a function and giving it an environment/context?
<dminuoso>
grahamb: blocks/procs/lambda are more or less the same thing.
sand-bird has quit [Ping timeout: 240 seconds]
manson has joined #ruby
Snickers has joined #ruby
<grahamb>
dminuoso: well, the the `sum_of_nested_list` initialization happens when `lambda_with_recursive_callback` is expecting `arg`
matp has joined #ruby
<grahamb>
but `arg` is not getting bound to the `...do |arg, recurse|...` bit
saneax-_-|AFK is now known as saneax
<dminuoso>
grahamb: The combinator you are looking at and the previous are basically identical.
<dminuoso>
grahamb: The difference between "passing a block to a function" and "passing a lambda as an argument" is non-existent for the purpose of understanding the concept of the code.
<dminuoso>
Consider them to be the same (for now)
<grahamb>
if i think of them the same, though, the bindings do not line up.
newcomer25 has left #ruby [#ruby]
<dminuoso>
what bindings?
<dminuoso>
there is only parameters used.
Bish has quit [Ping timeout: 244 seconds]
jaruga___ has joined #ruby
<grahamb>
when lambda_with_recursive_callback is called, that first lambda is immediately invoked and binds x to `lambda do |myself|`, right?
Bish has joined #ruby
<dminuoso>
grahamb: yes
Dimik has quit [Ping timeout: 244 seconds]
<grahamb>
so the recursive "trick" is set up. the way it looks to me, it's now expecting "arg", is that still correct?
<dminuoso>
no
<grahamb>
ok. maybe that's where my misunderstanding is.
<grahamb>
how do you see it?
<dminuoso>
grahamb: It would be easier to discuss the previous snippet.
<dminuoso>
The one using only lambdas.
harai has quit [Ping timeout: 264 seconds]
jazzonmym1nd has joined #ruby
al2o3-cr has joined #ruby
<grahamb>
ok, sure.
hahuang61 has joined #ruby
<grahamb>
previous one. immediately invokes, passing in the "guts" if you will (lambda do |arg, recurse|...).
<grahamb>
so that is bound to "fn"
workmad3 has joined #ruby
fivmo has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
AndrewIsHere has joined #ruby
<grahamb>
inner lambda invokes, binds "x" to "lambda do |myself| ..."
<grahamb>
returns a lambda expecting "arg". done at this point.
jazzonmym111nd has quit [Ping timeout: 240 seconds]
<dminuoso>
grahamb: I think that variant is tons more readable.
<dminuoso>
All your example does, is provide some wrapper function that prepares the entirety, so that you only have to provide the recursive lambda in line 6.
AndrewIsHere has quit [Ping timeout: 250 seconds]
Ishido has quit [Ping timeout: 260 seconds]
aryaching has joined #ruby
jinie has joined #ruby
<grahamb>
dminuoso: ok, that's fine. but like i said, my understanding of that was fine (i thought). the block is still not clear.
<grahamb>
and that's the part i'm concerned with atm.
giz|work has joined #ruby
<grahamb>
so if it's a tangent to understand blocks, i'm ok with that.
<apeiros>
if understanding blocks themselves is the issue, then a recursive-lambda might be a bit heavy as an entry point
pjanzen has joined #ruby
<grahamb>
apeiros: well, i suggested what i think is happening with the blocks, because i have inklings about it.
<grahamb>
i've also seen them in less hairy contexts, and i understood them there.
<dminuoso>
grahamb: Let's assume a lambda and block is the same. When you call a function and pass a block, it's basically just an additional parameter containing this "lambda/block" you specified.
<dminuoso>
grahamb: yield just calls that block.
<dminuoso>
and when I say function I mean method of cours.e
fivmo has joined #ruby
<apeiros>
given `foo do |a,b,c| a+b+c end`, then the implementation `def foo; x = yield(1,2,3); end;` is equivalent to `def foo(&block); x = block.call(1,2,3); end` - if that's of any help. former does not explicitly have a proc, latter does.
axl_ has joined #ruby
stamina has joined #ruby
giz|work|2 has joined #ruby
f4cl3y has joined #ruby
futilegames has joined #ruby
giz|work|2 has quit [Client Quit]
axl_ has quit [Ping timeout: 244 seconds]
zack6849 has quit [Ping timeout: 276 seconds]
Ishido has joined #ruby
futilegames has quit [Client Quit]
giz|work has quit [Ping timeout: 252 seconds]
postmodern has quit [Quit: Leaving]
ta_ has joined #ruby
axl_ has joined #ruby
<grahamb>
apeiros: ok, so it is similar to supplying context/environment when thinking from a different perspective?
<apeiros>
not sure what you understand by that.
<apeiros>
it's similar to passing in a function.
<dminuoso>
grahamb: Between those examples, nothing changed
<grahamb>
dminuoso: can you rewrote your example using a block in the same way that my example did?
ta_ has quit [Ping timeout: 252 seconds]
<grahamb>
apeiros: but it seems different because when you pass a block seems less important than when something is expecting a function next.
<apeiros>
can you make an example of "something expecting a function next"?
<dminuoso>
grahamb: I recommend starting with blocks at the beginning.
<grahamb>
*now* it will work!
<dminuoso>
Not recursive lambdas.
<grahamb>
the last thing was passed!
<grahamb>
right?
astrobun_ has quit [Remote host closed the connection]
<grahamb>
grahamb: here, i did it for you. don't even have to fire up irb: https://eval.in/628557
<grahamb>
see how i added the *last thing it needed*? `arg`?
mikecmpbll has joined #ruby
zack6849 has joined #ruby
zack6849 has quit [Changing host]
zack6849 has joined #ruby
<dminuoso>
grahamb: So I just wasted an hour because you can't read?
<dminuoso>
If all you needed to know was "hey how do I invoke this recursive lambda", you should have said so.
fivmo has quit [Ping timeout: 244 seconds]
<grahamb>
dminuoso: no, i knew how to do that from the beginning.
<grahamb>
dminuoso: and i tried telling you. but you kept asserting that that was the problem.
arnonhon_ has joined #ruby
<grahamb>
dminuoso: that was me finally proving that i knew that since you didn't understand when i simply said i understood.
aidalgol has joined #ruby
edwinvdgraaf has joined #ruby
Snowy has joined #ruby
_joes___ has joined #ruby
<dminuoso>
grahamb: All I assert is that you demonstrate a lack of understanding of blocks.
<grahamb>
dminuoso: *i know*. and yet you offered no help in that regard!
<grahamb>
every time, "let's go to the last example"
<grahamb>
then you rewrote it. without blocks.
<grahamb>
and explain what i know to me some more.
<dminuoso>
Im sorry, if you can't grasp what Ive been chanting all along, that it makes absolutely no difference whether you use a block or a lambda - then I cant help you.
<dminuoso>
If you keep insisting that it needs to be explained in terms of blocks, then you need to buy a beginners book on Ruby.
astrobun_ has joined #ruby
<dminuoso>
That is the last bit I will say on the subject. Good luck.
arnonhongklay has quit [Ping timeout: 276 seconds]
<grahamb>
dminuoso: well, your examples didn't catch what my question was about, so it seems you never understood what i was after in the first place.
kjellpropell has joined #ruby
hk238 has joined #ruby
gypki has joined #ruby
arnonhon_ has quit [Read error: No route to host]
jeremM34 has joined #ruby
Burgestrand has quit [Read error: Connection reset by peer]
Burgestrand has joined #ruby
arnonhongklay has joined #ruby
phredus has quit [Remote host closed the connection]
phredus has joined #ruby
kalpol has joined #ruby
<kalpol>
I do a Poloniex.available_account_balances and I get this "=> "{\"exchange\":{\"BTC\":\"0.81278949\",\"XMR\":\"7.29447699\"}}"" from Poloniex's API. It is a string. When I do a .as_json, how can I grab the BTC or XMR value? Or any other way?
<apeiros>
as_json is Object -> String
<apeiros>
(aka "serialization")
<workmad3>
kalpol: you want to JSON.parse it
Burgestrand has quit [Client Quit]
<apeiros>
you want deserialization (String -> Object), and for that ^
Burgestrand has joined #ruby
<kalpol>
like JSON.parse(element)?
<apeiros>
assuming your string is in the variable "element", yes.
<workmad3>
apeiros: well, in rails, `as_json` is Object -> Hash, as it basically 'prepares' an object for serialisation :)
<apeiros>
workmad3: right. read that as to_json :D
<apeiros>
don't we have a new way now even? #serializable or somesuch?
<workmad3>
serializable_hash
* apeiros
usually uses presenters anyway
<kalpol>
workmad3: works perfectly. thank you
<workmad3>
I tend towards AM:S most of the time
nikivi has quit [Quit: irc]
<workmad3>
kalpol: np :)
aidalgol has quit [Ping timeout: 240 seconds]
bad_ip has quit [Read error: No route to host]
bad_ip has joined #ruby
<jeremM34>
Macdonald or pizza ? Please help me !!!
<workmad3>
jeremM34: pizza!
Burgestrand has quit [Ping timeout: 276 seconds]
<jeremM34>
Okay pizza !! XD
kalpol has quit [Quit: Page closed]
<workmad3>
jeremM34: you need pretty good burgers to contend with even a bad pizza... and mcdonalds isn't a good burger
<jeremM34>
So ................................... PIZZAAAAAAA !!! =D
<hanmac>
selfmade pizza or selfmade burger are the best!
<jeremM34>
I agree but at work, do pizza myself ... Mmh ... Maybe one day =)
<hanmac>
imo a good pizza does need to have a third dimension XD
Spami has quit [Quit: This computer has gone to sleep]
Burgestrand has joined #ruby
<jeremM34>
Todo: Command Pizza : Check !
Burgestrand has quit [Read error: Connection reset by peer]
SuperTaz has quit [Ping timeout: 276 seconds]
LambdaSix has joined #ruby
daffy_duck has joined #ruby
mikhael_k33hl has joined #ruby
<mikhael_k33hl>
I'm trying to create tests for a ruby script/program. How do I mock the required classes and test a particular method? I'm using MiniTest
<dminuoso>
mikhael_k33hl: You just create a new mock object and tell it to expect a method
SuperTaz has joined #ruby
_joes___ has left #ruby [#ruby]
ukk has quit [Quit: WeeChat 1.5]
ukk has joined #ruby
_joes___ has joined #ruby
Burgestrand has joined #ruby
Burgestrand has quit [Client Quit]
Burgestrand has joined #ruby
Chair is now known as Couch
Burgestrand has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
_joes___ is now known as _joes_
_joes_ has quit []
_joes_ has joined #ruby
Burgestrand has joined #ruby
spectrum has joined #ruby
Burgestrand has quit [Client Quit]
Jonathel has joined #ruby
edwinvdgraaf has quit [Ping timeout: 244 seconds]
astrobun_ has quit [Remote host closed the connection]
<Jonathel>
has anyone got experience with ruby applications using AWS/SQS ?
<dminuoso>
Jonathel: Just ask your question, instead of asking whether there is someone experienced around.
<Jonathel>
well its more of a design question.. how do i implement background processing for sqs jobs
jaruga____ has joined #ruby
<mikhael_k33hl>
dminuoso: How about if a class I'm trying to tests have a lot of require_relative classes. How do I pass the mocked objects to it?
k3rn31 has quit [Ping timeout: 264 seconds]
jaruga___ has quit [Ping timeout: 244 seconds]
edwinvdgraaf has joined #ruby
<dminuoso>
mikhael_k33hl: I think there may be a confusion about what mocking does.
ferr has joined #ruby
<dminuoso>
mikhael_k33hl: Can you gist a small code to show what you are trying to do?
<Smoht>
the _ function is provided by gettext, a library for translating programs
<Smoht>
as you see there is some string interpolation going on
<dminuoso>
Possibly. Does _() return a string?
<Smoht>
yes dminuoso
<tobiasvl>
then that code should work
<tobiasvl>
interpolating into the returned string from _
<Smoht>
yes yes
<apeiros>
#ruby - so fast they help before the question was asked…
<apeiros>
slow down you great people :D
<Smoht>
the thing is, I'd like to do something like
<tobiasvl>
snicker
<dminuoso>
Smoht: Use public_send
* dminuoso
hides from apeiros
<Smoht>
_("%{@min_length} some text").convenient_interpolation
<apeiros>
_("#{@min_length} some text")
crystal77 has joined #ruby
<dminuoso>
Smoht: Refine String, add the method convenient_interpolation
<dminuoso>
!next
<Smoht>
yeah
yuki_is_bored has joined #ruby
<apeiros>
no need for % there
<apeiros>
the % is nice if your translation "key" is in a variable. i.e. not written at the same place as where you interpolate.
<canton7>
won't that cause the value of '@min_length' at whenever the string was extracted to be baked into the localized string?
<canton7>
which is NOT what you want
<apeiros>
canton7: gettext works by translating a full string, not a key.
<canton7>
yes indeed
<apeiros>
i.e. unlike I18n in rails
<apeiros>
oh
senayar has joined #ruby
<canton7>
but won't '_("#{@min_length} some text")' cause the full string to be e.g. "3 some text", which will get translated into other languages like that
<yuki_is_bored>
Hello, I'm having a problem here. In json["result"].each { |u| updates << Update.new(u) }. u is always nil, but in json["result"].each { |u| p u.class }. prints Hash.
<yuki_is_bored>
I tried u.dup
<canton7>
so there's no chance for you to insert the *actual* value of @min_length
<apeiros>
I should read the code more carefully
<apeiros>
yes, you're right canton7.
<apeiros>
not what they want.
<canton7>
you want to give your translators the string '%{min_length} some text' - that exact literal string - so they translate it with the placeholder intact
<grahamb>
and if you weren't'sure what i was talking about when i asked if blocks create a new environment (which they do), Ruby Under a Microscope could give you a little insight there
mjuszczak has joined #ruby
<dminuoso>
grahamb: Nobody said blocks are like functions.
<dminuoso>
Blocks are like lambdas.
<dminuoso>
grahamb: And I have read Ruby under a Microscope enough to have hacked Ruby myself, thank you for the recommendation though.
synthroid has joined #ruby
<dminuoso>
grahamb: And if you had bothered to look at my last complete recursive example, you could have seen that what you say is simply not true.
<Smoht>
uhm
jeremM34 has quit [Quit: Leaving]
Ropeney has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
last_staff has quit [Quit: last_staff]
<Smoht>
I'm dealing with binding() now
<grahamb>
ahh, functions/lambdas, my mistake.
<Smoht>
I can access instance variables like this
<grahamb>
dminuoso: well, chapter 8 discusses environments a bit. :)
<Smoht>
@x = 1; binding.eval("@x")
<dminuoso>
grahamb: I think you still do not understand blocks completely.
<grahamb>
and what part is not true? i've said quite a bit. :)
<dminuoso>
grahamb: "blocks must be passed *upfront* to methods"
<Smoht>
but how can I access @x from binding without using eval?
<dminuoso>
That statement makes absolutely no sense.
<grahamb>
sure it does.
<dminuoso>
Smoht: instance_variable_get
<dminuoso>
grahamb: No it does not.
valkyr1e has quit [Quit: Bye.]
<grahamb>
how so?
<dminuoso>
There is very little difference to these two: a = proc{}; foo(a); foo {}
<Smoht>
dminuoso, instance_variable_get works for self
<Smoht>
I mean
jtdoncas has joined #ruby
<Smoht>
@x = 1; self.instance_variable_get("@x")
<Smoht>
is one thing
<dminuoso>
grahamb: In fact, since you want to go into the details: Both are passing a "BLOCK" to the method foo. The only difference is, one is hidden inside a proc (or lambda) object but an explicit parameter, and the other without a ruby object in an implicit parameter.
<dminuoso>
grahamb: Do you even understand what yield does?
<grahamb>
yes.
<grahamb>
now can you get the proc into bar after having already called foo without supplying it?
imr has joined #ruby
<dminuoso>
What?
<grahamb>
did you look at the paste?
<dminuoso>
You are just babbling.
<grahamb>
no, i'm really not. you get really close to answering, then jsut go off on a tangent
<Smoht>
grahamb, I didn't follow closely
<dminuoso>
Yes you really are.
<Smoht>
are you looking for function currying?
vondruch has quit [Ping timeout: 264 seconds]
Madplatypus has quit [Quit: Connection closed for inactivity]
<grahamb>
Smoht: in my paste, i have bar. it already called the method foo. foo yields, but no proc was supplied in the bar invocation. can that proc be supplied after the fact?
<grahamb>
or is bar a lost cause at this point?
jphase has joined #ruby
<dminuoso>
grahamb: Are you trying to modify a lambda?
<Smoht>
my brain hurts
hutch34 has quit [Ping timeout: 276 seconds]
millerti has joined #ruby
<apeiros>
Smoht: btw., if you want to allow escaping, you need /(?<!\\)(\\\\)*\\%)|%…/) and test for leading \ in the block. hope I remember that right, didn't test it :D
edwinvdgraaf has quit [Ping timeout: 250 seconds]
<grahamb>
dminuoso: no, i'm asking if what i asked is possible.
edwinvdgraaf has joined #ruby
<dminuoso>
grahamb: bar is a variable.
<grahamb>
so the proc needed to be passed when i called the method, right?
johnmilton has quit [Ping timeout: 252 seconds]
<dminuoso>
grahamb: what proc?
<dminuoso>
grahamb: the method foo() returns a lambda.
<grahamb>
*if* i were to supply one
<dminuoso>
grahamb: the contents of the lambda are evaluated when foo() is called.
johnmilton has joined #ruby
mjuszczak has quit []
<grahamb>
dminuoso: hold on, hold on.
<Smoht>
grahamb, I think I made it work
<Smoht>
let me paste the think
<Smoht>
thing*
<grahamb>
*if* i wanted to supply a proc, i need to do it when i called `foo`, right?
<dminuoso>
grahamb: a proc is just an object.
<yuki_is_bored>
is there some good linters for ruby?
<apeiros>
>> "%foo \\%bar \\\\%baz".gsub(/(?<!\\)(?:\\\\)*\\%\w+|%(\w+)/) { |m| m[0] == '\\' ? m[1..-1] : $1.upcase } # example using upcase instead of substitution, just to get the idea (and with fixed regex)
<apeiros>
grahamb: I don't understand what you're trying to say there, for that reason: no, I wouldn't say that.
<grahamb>
dminuoso: your snippet doesn't yield.
<dminuoso>
grahamb: It doesnt matter.
<dminuoso>
grahamb: Seriously, stop holding onto whatever you are trying to force into your editor.
<apeiros>
dminuoso: are we at a point with grahamb were we consider proc =~ block for the sake of easier explanation? or should I point out the difference?
<dminuoso>
grahamb: the main difference is that blocks are not procified.
jhooker has joined #ruby
<dminuoso>
or objectified.
<dminuoso>
thats it.
<apeiros>
block -> not an object
<apeiros>
proc -> an object
<grahamb>
apeiros: you understood the `bar = foo()` bit. if foo yields, is there a way to make it work with `bar`?
<gregf_>
grahamb: you need to pass a block to foo .. what apeiros , dminuoso are trying to say
<apeiros>
blocks -> only exist as special syntax passed to methods as block argument
<dminuoso>
grahamb: There you can do it with blocks too.
<grahamb>
gregf_: that's the point i'm trying to make.
<dminuoso>
grahamb: the problem with "yield" is just that it always operates on the block_given to the method.
<dminuoso>
grahamb: its just a syntax thing, it has nothing to do with blocks.
<apeiros>
procs -> are objects and thus can be assigned to variables, can receive method invocations, can be passed as normal arguments to methods, can be passed as blocks to methods (using &proc_var syntax)
<dminuoso>
grahamb: stop using yield, and things will begin to make sense.
<apeiros>
grahamb: you can't invoke foo() without a block if it yields. that'll raise an exception.
<apeiros>
grahamb: yield *requires* a block having been passed.
<apeiros>
you can test whether a block was passed using `block_given?`
<dminuoso>
grahamb: Can you please stop arguing with everybody. Either you know the details, then you wouldnt be asking, or consider listening a bit and understanding.
<grahamb>
dminuoso: no, it's just i keep asking a question, then everyone suggests other things.
<apeiros>
I didn't follow the conversation. but what I've read looked consistent.
d0lph1n98 has joined #ruby
<grahamb>
like, can we pause, one second, i'll ask the question, and someone can answer the question. not ask what i'm doing. not offer a different approach. just answer the question.
malconis has quit [Remote host closed the connection]
<dminuoso>
grahamb: Your question still makes no sense.
anisha_ has quit [Quit: This computer has gone to sleep]
<apeiros>
grahamb: if your question makes sense, yes.
<apeiros>
but lets try. if neither me nor dminuoso can make sense of your question, we'll see how we proceed.
<dminuoso>
grahamb: don't use yield.
<dminuoso>
grahamb: look at the snippet you have repeatedly ignored: https://eval.in/628739
<dminuoso>
and learn.
<grahamb>
dminuoso: please just follow along
<dminuoso>
grahamb: No, you follow along. Im trying to teach you the mechanics so you can apply it to your problem.
<grahamb>
apeiros: ok, you see `bar`, correct?
jhooker has quit [Ping timeout: 276 seconds]
<apeiros>
grahamb: yes
<grahamb>
apeiros: i've not provided a block in my call to `foo`. this is troubling.
jhooker has joined #ruby
<apeiros>
grahamb: ok.
<grahamb>
apeiros: at this point, is there anyway to provide that block to `bar`? or do i just need to call `foo` again and provide the block?
<apeiros>
grahamb: no. there isn't.
ramortegui has quit [Quit: Ex-Chat]
<grahamb>
apeiros: question answered.
<apeiros>
you can't provide blocks to variables. period.
quiller has quit [Ping timeout: 264 seconds]
<gregf_>
>> def foo; proc { |x| x * x };end; pr = foo do |x| x * x end; p pr; p pr.call(10) # grahamb that returns a proc. but what apeiros,dminuoso were saying was, you have to call it thereafter
<ruby[bot]>
gregf_: # => #<Proc:0x4071975c@/tmp/execpad-78b689af3788/source-78b689af3788:2> ...check link for more (https://eval.in/628743)
<apeiros>
blocks are passed to methods, and methods only.
<apeiros>
blocks are arguments. you can't pass any other argument to an object either.
<grahamb>
apeiros: ok, so the block must be provided when the method is called?
<apeiros>
only methods take arguments.
<dminuoso>
grahamb: no it does not.
<dminuoso>
grahamb: you can pass the block later.
<grahamb>
apeiros: do you agree with dminuoso here?
<apeiros>
dminuoso: I find that claim misleading. you can pass a block later *if* you construct the thing differently.
<apeiros>
and you don't pass it to "bar" then.
<dminuoso>
apeiros: Its hardly misleading as I have shown him HOW and explained WHY about 4 times alreaydin the past 15 minutes.
<apeiros>
I presume you'd pass it to bar.call
<grahamb>
apeiros: with the current construction.
davedev24 has joined #ruby
<apeiros>
dminuoso: ok, fair.
<grahamb>
dminuoso: i know, and that is not what i'm asking.
<dminuoso>
grahamb: Tell me which company you work at, so I know which companies I must avoid so I don't have to clean up your code in a few years ago.
<apeiros>
grahamb: lambda in line 2-4 closes over the current context. the yield is bound to the context of the `foo` method. so the yield will yield the block passed to foo at the time the lambda was constructed.
matp has quit [Ping timeout: 244 seconds]
<gregf_>
grahamb: procs and lambda's are different from blocks. that i guess is your confusion
kobain has joined #ruby
<grahamb>
gregf_: no, i understand that.
<grahamb>
but someone said that i didn't need to provide the block when the method was called, and i'm just making sure that i do.
<grahamb>
i think apeiros has confirmed that.
<gregf_>
yes, yield only works with blocks
<grahamb>
right.
<apeiros>
grahamb: I confirmed it for the specific code you provided.
<grahamb>
and the block must be provided when the method is called.
<apeiros>
grahamb: I'm quite certain dminuoso showed you how you could provide the block at a later time.
<gregf_>
>> def foo x; yield x;end; foo(10) {|x| x*x } # like that
<dminuoso>
gregf_: while in itself correct it wont work in his context.
<grahamb>
apeiros: but with a yield.
<dminuoso>
grahamb: why do you insist on keyword_yield?
<grahamb>
dminuoso: because the code i'm reading uses it.
roger_rabbit has quit [Changing host]
roger_rabbit has joined #ruby
<apeiros>
with the yield keyword I can't currently think of a way to provide the block at another time, true.
tvw has quit [Remote host closed the connection]
arup_r has quit []
<apeiros>
s/another/a later/
<apeiros>
hm, no, actually "another" is appropriate.
davedev24 has quit [Ping timeout: 276 seconds]
<grahamb>
apeiros: that's what i wanted answered. thank you. :)
quiller has joined #ruby
<grahamb>
it was confusing, because i'm reading this code, and then dminuoso would say "but it is possible!" but that would be with different code that didn't yield.
<grahamb>
and i'
<apeiros>
careful
<apeiros>
code can yield without using the keyword "yield"
<apeiros>
programming is a pedantic thing. details matter.
<apeiros>
hence "didn't yield" != "didn't use the keyword yield"
<grahamb>
*didn't use yield
<grahamb>
apeiros: good call.
arashb has quit [Ping timeout: 252 seconds]
jobewan has joined #ruby
jobewan is now known as jobewan_away
jobewan_away is now known as jobewan
youch has joined #ruby
jtdoncas has quit [Ping timeout: 244 seconds]
AndrewIsHere has joined #ruby
lightheaded has quit [Remote host closed the connection]
lightheaded has joined #ruby
cpruitt has joined #ruby
d0lph1n98 has quit [Quit: leaving]
Vingador has joined #ruby
lheaded has joined #ruby
lightheaded has quit [Read error: No route to host]
x77686d has joined #ruby
glcx has joined #ruby
glcx has quit [Changing host]
glcx has joined #ruby
AndrewIsHere has quit [Ping timeout: 252 seconds]
Immune_ has joined #ruby
blackgoat has quit [Quit: WeeChat 1.5]
swills has joined #ruby
Immune has quit [Ping timeout: 252 seconds]
Snickers has quit [Ping timeout: 260 seconds]
e4xit_ has joined #ruby
x77686d has quit [Remote host closed the connection]
Immune_ has quit [Ping timeout: 252 seconds]
e4xit has quit [Ping timeout: 265 seconds]
e4xit_ is now known as e4xit
hammond is now known as affluent
vuoto has joined #ruby
moss has quit [Quit: QUITTING]
pokalyis has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<atmosx>
Yes, I use it with Sinatra for small web projects
<atmosx>
bbl
senayar has quit []
Todd has joined #ruby
fluffyKat has quit [Quit: Leaving]
coolboy has quit [Remote host closed the connection]
coolboy has joined #ruby
pokalyis has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
GodFather has quit [Ping timeout: 244 seconds]
Bish has quit [Ping timeout: 260 seconds]
AzureStigma has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ajsharma has joined #ruby
Bish has joined #ruby
pokalyis has joined #ruby
galeido has quit [Ping timeout: 264 seconds]
Uranio has joined #ruby
nitric has joined #ruby
Uranio has quit [Client Quit]
skweek has quit [Ping timeout: 250 seconds]
coolboy has quit [Remote host closed the connection]
pokalyis has quit [Max SendQ exceeded]
vuoto has quit [Remote host closed the connection]
coolboy has joined #ruby
vuoto has joined #ruby
pokalyis has joined #ruby
naftilos76 has quit [Quit: Αποχώρησε]
vuoto has quit [Remote host closed the connection]
vuoto has joined #ruby
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
Ruby_Rocks_007 has joined #ruby
jtdoncas has joined #ruby
sdothum has joined #ruby
coolboy has quit [Remote host closed the connection]
shinnya has quit [Ping timeout: 260 seconds]
cschneid has quit [Ping timeout: 250 seconds]
synthroid has joined #ruby
coolboy has joined #ruby
wrkrcoop has joined #ruby
theRoUS has left #ruby ["Off to another part of the maze of twisty little passages"]
<wrkrcoop>
my co-workers wrote if elseif end
hahuang61 has joined #ruby
<wrkrcoop>
im telling them we need to have an else because if elsif end is not idiomatic ruby
<wrkrcoop>
am i wrong?
DoubleMalt has joined #ruby
<wrkrcoop>
i thought an alternative would be to use a switch statement
al2o3-cr has joined #ruby
Yzguy has joined #ruby
skweek has joined #ruby
cschneid has joined #ruby
pokalyis has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pokalyis has joined #ruby
<chris2>
both can make sense
<Yzguy>
so I have a question. In the rails console I can do like "person.team.name" and get what I expect, but if I do it in a view it says name is an undefined method
<wrkrcoop>
chris2: you think if elsif end is good?
<chris2>
it means something different than if..else..end
<wrkrcoop>
i never see if elsif
cschneid_ has joined #ruby
<chris2>
perhaps case when; when; end is better
<wrkrcoop>
i suggested raising in the else statement
<cschneid_>
Is there a tool like rubular for testing ruby-flavored regexes, but on the command line?
hahuang61 has quit [Ping timeout: 250 seconds]
<cschneid_>
like, I can do it in IRB, but that's not as dynamic
leftpad has quit [Ping timeout: 244 seconds]
rodfersou|afk is now known as rodfersou
mikecmpbll has quit [Quit: inabit. zz.]
<havenwood>
Mattx: You might look at Sequel as well. It's quite nice. Roda+Sequel ftw!
<Mattx>
I'm reading a review of the differences with AR. What do you like of Sequal?
<havenwood>
wrkrcoop: There's nothing inherently wrong with `elsif`. Maybe show the code in question?
kentnl has joined #ruby
kentnl has quit [Changing host]
kentnl has joined #ruby
<havenwood>
Mattx: It can be used without the ORM portion and has a nice plugin system so you don't get the kitchen sink unless you want it, then it's there.
<havenwood>
Mattx: Roda's plugin system is modeled on Sequel's.
kent\n has quit [Disconnected by services]
kentnl is now known as kent\n
zacts has quit [Ping timeout: 265 seconds]
ddffg has joined #ruby
<Mattx>
Oh wait, I just read there are problems with threading in AR
flashpoint9 has joined #ruby
<Mattx>
Now I remember connections getting exhausted in AR
<Mattx>
Was it solved in Sequel?
vuoto has quit [Remote host closed the connection]
vuoto has joined #ruby
vuoto has quit [Remote host closed the connection]
oetjenj has joined #ruby
vuoto has joined #ruby
Dimik has joined #ruby
wrkrcoop has quit [Quit: wrkrcoop]
crystal77 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Snowy has quit [Remote host closed the connection]
synthroi_ has joined #ruby
vuoto has quit [Remote host closed the connection]
Snowy has joined #ruby
vuoto has joined #ruby
vuoto has quit [Remote host closed the connection]
vuoto has joined #ruby
vuoto has quit [Remote host closed the connection]
jhboricua has joined #ruby
vuoto has joined #ruby
vuoto has quit [Remote host closed the connection]
vuoto has joined #ruby
wrkrcoop has joined #ruby
mark_66 has quit [Remote host closed the connection]
synthroid has quit [Ping timeout: 250 seconds]
tdy has quit [Ping timeout: 244 seconds]
Snowy has quit [Ping timeout: 240 seconds]
TPug has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<cschneid_>
havenwood: heh. I'm ok at regexes, but I always have to test them to get exactly what I want when it starts doing nested captures, and lookaheads and stuff. Was hoping for a little tool that basically does rubular, but from a console right next to my editor
<cschneid_>
havenwood: what you wrote is the very core of that idea for sure :)
<Talltree>
are there some dev tools out there where it runs the rb file on save?
<SeepingN>
you need a tool for that?
TPug has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Talltree>
i'm a noob when it comes to "vanilla" ruby deving
<Talltree>
only used to rails.
<workmad3>
Talltree: that's effectively what the syntactic plugin for vim does... it runs the file and looks for syntax errors in stderr in order to show you them in the editor
ben______ has quit [Remote host closed the connection]
<SeepingN>
why not just alt-tab to terminal, up arrow to run "ruby myfile.rb"
<Talltree>
i'm using guard with rails
<SeepingN>
alt-tab back to edit
<Talltree>
alt tab is annoying, doing it a million times a day is annoying
<workmad3>
Talltree: the question is - what exactly are you wanting out of the 'autorun' aspect?
* SeepingN
shrugs. been doing it for 30 years
<Talltree>
workmad3: not having to alt-tab :D
AzureStigma has quit [Client Quit]
Spami has quit [Quit: This computer has gone to sleep]
<Talltree>
i'm coming from a web background, and there are plenty of solutions to auto-refresh or even just inject new css into a site on save
<SeepingN>
1 line bash could do it
wrkrcoop has joined #ruby
<SeepingN>
check every 5 seconds for file modification date change, run, loop. ugly but quick
SteenJobs has joined #ruby
<bjmllr>
gem install rerun; rerun -x ruby blah.rb
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
<workmad3>
Talltree: right... but a plain ruby script rarely has the same sort of output, so I'm wondering what the end goal is for having it run on save... is it to check for errors? What happens if the script is writing files or something? Are you running a GUI app and want to restart/reload parts of it on save? what's the goal you're wanting?
<SeepingN>
might consider RubyMine or Sublime Text. I use sublime but not sure about it running things as I have to run all my code on a remote server anyway
Velizar has quit [Ping timeout: 244 seconds]
<Talltree>
i switched from sublime to atom, because i like it better... there is a script plugin for atom, wondering if it has a option to autorun
<Talltree>
workmad3: yes i considered all of that, right now its mainly debugging... i would like to do it in rails while using the normal rb syntax i guess
Coldblackice has quit [Read error: Connection reset by peer]
nettoweb has joined #ruby
smathy has joined #ruby
jaruga____ has quit [Quit: jaruga____]
binaryplease1 has joined #ruby
jhack has quit [Quit: jhack]
ramortegui has joined #ruby
binaryplease has quit [Ping timeout: 240 seconds]
symm-_ has joined #ruby
travisxcode has joined #ruby
pawnbox has quit [Remote host closed the connection]
travisxcode has quit [Client Quit]
pawnbox has joined #ruby
travisxcode has joined #ruby
ramfjord_ has joined #ruby
symm-_ is now known as symm-
postmodern has joined #ruby
whathappens has quit [Read error: Connection reset by peer]
whathappens has joined #ruby
anisha has joined #ruby
ramfjord has quit [Ping timeout: 240 seconds]
coolboy has quit [Ping timeout: 265 seconds]
binaryplease1 is now known as binaryplease
tomchapin has joined #ruby
sepp2k has quit [Quit: Leaving.]
johnmilton has joined #ruby
jphase has joined #ruby
Vingador has quit [Remote host closed the connection]
hutch34 has quit [Ping timeout: 265 seconds]
johnmilton has quit [Ping timeout: 276 seconds]
k3rn31 has joined #ruby
whathappens has quit [Remote host closed the connection]
Yzguy has joined #ruby
Coldblackice has joined #ruby
MrBusiness2 has joined #ruby
Spami has quit [Quit: This computer has gone to sleep]
<apeiros>
Smoht: yes
MrBusiness3 has quit [Ping timeout: 250 seconds]
wrkrcoop has quit [Quit: wrkrcoop]
MrBusiness has joined #ruby
flashpoint9 has quit [Remote host closed the connection]
hobodave_ has joined #ruby
snguyen has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tvon has joined #ruby
claudiuinberlin has quit [Remote host closed the connection]
elifoster has joined #ruby
MrBusiness2 has quit [Ping timeout: 250 seconds]
Spami has joined #ruby
theery has quit [Remote host closed the connection]
hobodave has quit [Ping timeout: 250 seconds]
MrBusiness2 has joined #ruby
jhboricua has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 252 seconds]
alfiemax has joined #ruby
lxsameer has joined #ruby
zeroDi has quit [Quit: WeeChat 1.5]
<Smoht>
apeiros, String#% essentially uses sprintf, so I had this idea of feeding into sprintf the string and an adapter hash-like object that wraps `self`
AzureStigma has joined #ruby
<Smoht>
but apparently native methods ignore virtual methods
<Smoht>
so I had to discard this idea
stamina has joined #ruby
AzureStigma has quit [Client Quit]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
MrBusiness has quit [Ping timeout: 250 seconds]
jenrzzz has joined #ruby
<apeiros>
Smoht: I don't follow
tomaz_b has joined #ruby
johnmilton has joined #ruby
matp has quit [Ping timeout: 250 seconds]
tyang has quit [Ping timeout: 244 seconds]
<hightower>
Hey folks, how about some expert advice here -- I have: module XYZ def self.some_method() end end. Is there a way to later have some_method() become a method on a class in which this module is included, but without using the "def self.included( cls)"?
<apeiros>
hightower: "a method on the class" is ambiguous
<Smoht>
but it can't possibly work so whatever I will use gsub
<apeiros>
a *class* method on the class, or an *instance* method?
<hightower>
toretore, yes, yes, without using extend manually. I'm looking for some way to define something on module XYZ which then becomes a method on a class, when module XYZ is included in it
<hightower>
apeiros, yes, a class method on the class
TPug has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tyang has joined #ruby
<apeiros>
in that case - no. extend is the way to go.
<hightower>
Ok, thanks
<apeiros>
Smoht: and you expected String#% to treat HashAdapter like a hash?
cdg has joined #ruby
ajsharma has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Smoht>
if it looks like a duck...
<apeiros>
Smoht: why not make it ivar_hash(self) and return an actual hash?
johnmilton has quit [Ping timeout: 244 seconds]
workmad3 has joined #ruby
kobain has quit [Read error: Connection reset by peer]
tvw has joined #ruby
edwinvdg_ has joined #ruby
<toretore>
Smoht: what is this for?
rodfersou is now known as rodfersou|afk
gurix has joined #ruby
gurix has quit [Client Quit]
mrx88 has joined #ruby
astrobun_ has quit [Ping timeout: 276 seconds]
<Smoht>
toretore, mostly to overcome the holiday boredom
Spami has quit [Read error: Connection reset by peer]
<Smoht>
and to make string interpolation a bit more cool with gettext, an internationalization library
Spami has joined #ruby
SteenJobs has quit [Quit: SteenJobs]
<Smoht>
cuz you cant' do
claudiuinberlin has joined #ruby
edwinvdgraaf has quit [Ping timeout: 260 seconds]
<Smoht>
_("translate my interpolate text #{some_expr}") and expect the _() function to find a translation
tdy has joined #ruby
<Smoht>
so you do _("%{some_var} text") % {some_var: some_expr}
thomas1 is now known as thomas
miqlas-H has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
ChiefAlexander has quit [Remote host closed the connection]
s1kx has joined #ruby
tdy has joined #ruby
rkazak has joined #ruby
jeremyhall has quit [Read error: Connection reset by peer]
blackmesa has joined #ruby
hobodave_ has quit [Quit: Computer has gone to sleep.]
RegulationD has quit [Remote host closed the connection]
<zenspider>
havenwood: you mean the github auto-generated tarballs, right?
<zenspider>
that's a whole different story and has NEVER been a rubygems usecase
SteenJobs has quit [Quit: peaceee]
davedev24 has joined #ruby
rkazak has quit [Ping timeout: 244 seconds]
vikaton has quit [Quit: Connection closed for inactivity]
cibs has quit [Ping timeout: 240 seconds]
da3mon has quit [Quit: cya...]
<havenwood>
zenspider: ahh, okay - so it wasn't ever intended to be installable from the auto-tarball?
blackmesa has quit [Ping timeout: 244 seconds]
cibs has joined #ruby
elastix has quit [Quit: elastix]
* havenwood
looks at what RVM is doing
<zenspider>
they build their own tarballs for manual installation... but mostly you use `gem update --system [version]` which installs the rubygems-update gem
allcentury has joined #ruby
darthvorik has joined #ruby
tmtwd has joined #ruby
flying has quit [Read error: Connection reset by peer]
Mattx has joined #ruby
spudowiar has joined #ruby
blackmesa has joined #ruby
<havenwood>
okay, and it's the github tarball that RVM is using
<zenspider>
I can't (read: won't) read all that crap. sorry.
<zenspider>
please switch to something more sensible than rvm. it just does too much
* mikecmpbll
<3s rvm
whathappens has quit [Remote host closed the connection]
Bish has quit [Ping timeout: 244 seconds]
edwinvdgraaf has quit [Ping timeout: 244 seconds]
Lord_of_Life has quit [Excess Flood]
TheCog has joined #ruby
mikecmpbll has quit [Quit: inabit.]
<havenwood>
zenspider: I don't use RVM but so many folk do...
meth has joined #ruby
<zenspider>
and?
Bish has joined #ruby
Lord_of_Life has joined #ruby
<TheCog>
ok, I have a super dumb question. In ruby when you use the = operator on two variables, you're just pointing the first variable at the second variable, which means any operations on the first variab;e cascade into the second, right?
<Antiarc>
It's the same object, you're just giving it a new name
<zenspider>
variables don't point at variables, ever... they point at objects. but that also depends on the type of the objects
<havenwood>
zenspider: I want Ruby to work for them! I don't know if I have the energy to fix this one though.
<zenspider>
eg, fixnums are always separate values
toretore has quit [Ping timeout: 240 seconds]
<Antiarc>
a = Object.new; b = a; a.object_id == b.object_id => true
<TheCog>
ok, here's the question then, how do you get around that, I would like to bring a fixnum from one variable, put it into a second variable, and alter the fixnum on the second variable while preserving the value on the first
<TheCog>
.dup works for strings
<TheCog>
but not fixnums
<Antiarc>
fixnums are immutable
<zenspider>
again, fixnums are always separate values
ajsharma has joined #ruby
<Antiarc>
The fixnum 5 is always the same object throughout the entire VM
<zenspider>
TheCog: these aren't dumb questions... but they're easily experimented with in irb
<zenspider>
very easy to experiment with such things
davedev24 has quit [Remote host closed the connection]
firstdayonthejob has quit [Ping timeout: 260 seconds]
cschneid_ has quit [Remote host closed the connection]
flashpoint9 has quit [Remote host closed the connection]
<TheCog>
ok, yes
edwinvdg_ has quit [Ping timeout: 244 seconds]
<TheCog>
thanks, sorry, I gogoled a bunch
<TheCog>
but I guess i wasnt explicit enough
flashpoint9 has joined #ruby
<TheCog>
should have fooled around on irb instead
yuki_is_bored has quit [Quit: Lost terminal]
nankyokusei has joined #ruby
<havenwood>
zenspider: Though it seem rbenv just does too much these days as well! (Granted not near so much.) When I heard rbenv was overriding the realpath shell builtin with a C extension I thought it was trolling, yet there it is...: https://github.com/rbenv/rbenv/blob/master/src/realpath.c
flying has quit []
<havenwood>
chruby ftw ;-)
flashpoint9 has quit [Ping timeout: 244 seconds]
<havenwood>
zenspider: Thanks for the feedback on the Github tarball! I didn't know it was not intended to be able to install RubyGems. (Though I'm having deja vu so maybe I should have known.)
nankyokusei has quit [Ping timeout: 276 seconds]
hutch34 has quit [Ping timeout: 244 seconds]
jhack has quit [Quit: jhack]
Snickers has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<zenspider>
_MY_ shell doesn't have realpath... so maybe that's why
allcentury has quit [Ping timeout: 260 seconds]
hazelux has joined #ruby
hazelux has quit [Client Quit]
monoprotic has quit [Remote host closed the connection]
<wrkrcoop>
hmmm i called .to_s on my timestamp and that seemed to get past that error
<zenspider>
it's a org.jruby.RubyString,org.jruby.RubyFixnum
jphase has joined #ruby
<wrkrcoop>
oh … so thats probably complaining about the timestamp not beging a string?
Lord_of_Life has quit [Excess Flood]
JoshS has quit [Ping timeout: 240 seconds]
<zenspider>
assuming your timestamp is actually a number... sure.
<zenspider>
but this isn't a ruby question anymore... it's a java library question? or jruby at the least. I think java library
EDT is now known as MAJORIER-CODE
Lord_of_Life has joined #ruby
SeepingN_ has quit [Excess Flood]
GodFather has quit [Ping timeout: 244 seconds]
nhhc has quit [Quit: Leaving]
MAJORIER-CODE is now known as EDT
nettoweb has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
EDT is now known as v-a-p-o-r--e-d-t
dionysus69 has joined #ruby
postmodern has quit [Ping timeout: 250 seconds]
hahuang61 has joined #ruby
jackjackdripper has quit [Quit: Leaving.]
jphase has quit [Remote host closed the connection]
AnarchyAo has quit [Ping timeout: 244 seconds]
harai_ has joined #ruby
postmodern has joined #ruby
harai has quit [Ping timeout: 260 seconds]
jkhl has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 276 seconds]
mikeliss has joined #ruby
Lucky_ABA has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
edwinvdgraaf has quit [Remote host closed the connection]
Lucky_ABA has joined #ruby
mikeliss has quit [Client Quit]
flashpoi_ has joined #ruby
hahuang61 has quit [Ping timeout: 250 seconds]
mikeliss has joined #ruby
hutch34 has joined #ruby
flashpoint9 has quit [Ping timeout: 250 seconds]
mikeliss has quit [Remote host closed the connection]
meth has quit [Quit: Bye!]
blackgoat has quit [Ping timeout: 252 seconds]
agent_white has quit [Quit: goin home]
smathy has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
hutch34 has quit [Ping timeout: 260 seconds]
dionysus69 has quit [Ping timeout: 244 seconds]
<hightower>
apeiros, toretore: regarding my question from earlier today, I've managed to do it: http://pastebin.ca/3705213
pokalyis has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<hightower>
apeiros, you might notice that the solution is a bit different than what I asked about (I only asked about a specific bit of the complete problem), but you might find it interesting
nitric has quit [Ping timeout: 258 seconds]
chestnutpie has joined #ruby
chestnutpie has quit [Max SendQ exceeded]
harai has joined #ruby
chestnutpie has joined #ruby
harai_ has quit [Ping timeout: 260 seconds]
davedev24 has quit [Remote host closed the connection]