ChanServ changed the topic of #ruby-lang to: Ruby 1.9.3-p125: http://ruby-lang.org | Paste >3 lines of text on http://pastie.org or use a gist
dhruvasagar has joined #ruby-lang
m3nd3s has joined #ruby-lang
Guest45047 has joined #ruby-lang
nanothief has joined #ruby-lang
Sailias has joined #ruby-lang
dhruvasagar_ has joined #ruby-lang
hahuang65 has joined #ruby-lang
kvirani has joined #ruby-lang
woollyams has joined #ruby-lang
jtoy has joined #ruby-lang
io_syl has joined #ruby-lang
Luxx_ has joined #ruby-lang
fayimora has joined #ruby-lang
shevy has joined #ruby-lang
garrettdavis has joined #ruby-lang
phlipper has joined #ruby-lang
garrettdavis has quit ["WeeChat 0.3.7"]
DEac- has joined #ruby-lang
t has joined #ruby-lang
Phrogz has joined #ruby-lang
voker57 has joined #ruby-lang
voker57 has joined #ruby-lang
sharkbyteusa has joined #ruby-lang
qpingu has joined #ruby-lang
WillMarshall has joined #ruby-lang
voker57_ has joined #ruby-lang
takaokouji has joined #ruby-lang
chimkan_ has joined #ruby-lang
voker57__ has joined #ruby-lang
woollyams has joined #ruby-lang
bryancp has joined #ruby-lang
ericmuyser has joined #ruby-lang
voker57 has joined #ruby-lang
voker57 has joined #ruby-lang
sharkbyteusa has joined #ruby-lang
andrewhl has joined #ruby-lang
AndChat| has joined #ruby-lang
shtirlic_ has joined #ruby-lang
savage-_ has joined #ruby-lang
fgomez has joined #ruby-lang
fvollero|gone has joined #ruby-lang
nofxxx has joined #ruby-lang
nofxx has joined #ruby-lang
ericmuyser has joined #ruby-lang
savage- has joined #ruby-lang
jmfcool has joined #ruby-lang
macmartine has joined #ruby-lang
seanstickle has joined #ruby-lang
gnufied has joined #ruby-lang
nofxxx has joined #ruby-lang
ankurgel has joined #ruby-lang
ankurgel has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
indeterminate has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
kentaur has joined #ruby-lang
nofxx has joined #ruby-lang
Sailias has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
Clordio has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
Clordio has joined #ruby-lang
nofxx has joined #ruby-lang
nofxx has joined #ruby-lang
chimkan_ has joined #ruby-lang
nofxx has joined #ruby-lang
gokul has joined #ruby-lang
nofxx has joined #ruby-lang
Clordio has joined #ruby-lang
jmoll has joined #ruby-lang
jmoll has quit [#ruby-lang]
ericmuyser has joined #ruby-lang
phipes has joined #ruby-lang
phipes has joined #ruby-lang
rippa has joined #ruby-lang
phipes has joined #ruby-lang
gouthamvel has joined #ruby-lang
sora_h has joined #ruby-lang
phlipper has joined #ruby-lang
rohit has joined #ruby-lang
ankurgel has joined #ruby-lang
io_syl has joined #ruby-lang
esad has joined #ruby-lang
whatnicknololder has joined #ruby-lang
whatnicknololder has quit ["Leaving"]
phipes_ has joined #ruby-lang
gix has joined #ruby-lang
nofxx has joined #ruby-lang
ericmuyser has joined #ruby-lang
dr0id has joined #ruby-lang
esad has joined #ruby-lang
yumatov has joined #ruby-lang
yxhuvud has joined #ruby-lang
savage- has joined #ruby-lang
dc5ala has joined #ruby-lang
gouthamvel has joined #ruby-lang
|Vargas| has joined #ruby-lang
|Vargas| has joined #ruby-lang
yumatov has joined #ruby-lang
ankurgel has joined #ruby-lang
JohnBat26 has joined #ruby-lang
Face_Is_Toe has joined #ruby-lang
<Face_Is_Toe> can ruby calculate massive numbers like 632382**518061?
kitallis has joined #ruby-lang
<erikh> yep
<erikh> might take a small eternity, but it can
<Face_Is_Toe> ok cool
<erikh> zenspider: http://augeas.net/index.html - not sure if you saw this but I figured it might tickle your parser fancy
<erikh> it's basically a tool to break down any configuration file style given a DTD into a DOM, more or less.
rking has joined #ruby-lang
x0F__ has joined #ruby-lang
scientes has joined #ruby-lang
<scientes> #ruby or #ruby-lang ?
<rking> scientes: You know, for some reason I haven't asked that question in years... I assumed it's always #ruby-lang.
vesan has joined #ruby-lang
<rking> But it seems this channel is half as populated. Not sure the purpose of each.
<scientes> it seems kinda funny to have two channels for the same purpose
datanoise has joined #ruby-lang
<rking> Moar Rubiness.
<scientes> STR2CSTR(RARRAY_PTR(orig_arg)[i]) --> StringValuePtr(RARRAY_PTR(orig_arg)[i]) ?
jbsan has joined #ruby-lang
jbsan has joined #ruby-lang
gouthamvel has quit [#ruby-lang]
<rking> scientes: Weird. I am not seeing STR2CSTR defined in the source tree I have.
<scientes> it was removed in 1.9.2
<rking> #define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
<rking> #define StringValuePtr(v) rb_string_value_ptr(&(v))
<rking> rb_string_value_ptr(volatile VALUE *ptr) { VALUE str = rb_string_value(ptr); return RSTRING_PTR(str); }
<scientes> char *rb_str2cstr _((VALUE,long*));
<scientes> #define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)
<rking> Hrm.. k
<scientes> so what do i change it to to get the same functionality
<rking> So, not exactly.
<scientes> now that its gone
<rking> OK, let me try to parse all of this.
<rking> I mean, you can always change STR2CSTR(foo) to rb_str2cstr((VALUE)(foo),0)
<rking> But maybe there is a more correct macro to call now.
<rking> StringValuePtr() is definitely not equivalent, I think we've established that much.
<scientes> i don't think rb_str2cstr exists anymore either?
<scientes> and that _() looks like gettext() which confuses the hell out of me
<rking> Oh, yes you're right.
<rking> _() is gettext stuff, yes -- but I don't see how it cmes into the equation.
<scientes> char *rb_str2cstr _((VALUE,long*));
* scientes has no idea what that does
<rking> Hrmm.. actually, I also don't know how to read that.
<rking> Oh, it looks like in Ruby it's not gettext (or do you have some strong reason to believe so?)
<scientes> no, it probably isn't, its just that i don't know any other meaning of the _ functional
<scientes> *function
<scientes> so it confuses me
<rking> It seems that it's for the old-style C function declarations.. it's #ifdef HAVE_PROTOTYPES define _(args) args .. #else define _(args) ()
voker57 has joined #ruby-lang
voker57 has joined #ruby-lang
jbsan has joined #ruby-lang
* scientes is cloning 1.8.7 to try to figure out what the function does...
<rking> scientes: Good hunting. That looks like it.
<scientes> so what do i need to change the line to?
<scientes> whats the diff between a pointer and an address?
<rking> Same
<scientes> #define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
<scientes> so that returns the pointer we want right?
<rking> Mehhhhh
thrcka has joined #ruby-lang
<rking> Actually, now that I look at this ruby-talk post closer, I am puzzled. The solution he does seems directly equivalent, to me. What good does the "VALUE tmp" have?
<scientes> EXACTLY
<scientes> is it like a ruby pointer and C pointer are differn't?
<rking> Wait, huh?
<scientes> well what does the VALUE macro do?
<rking> All I mean is that as far as I know this is identical: f(g()); vs. GsReturnType tmp = g(); f(tmp_
<rking> D'oh! messed up the last char.
<scientes> )
<rking> Thanks for the leg-up. =)
<scientes> wait, what does "VALUE" do there?
<rking> I'm working on that one. ctags didn't find it.
<scientes> obviously if you just stuck it in a variable and then passed that variable back, assuming that there was no implicit type conversion, it would be exactly the same
<scientes> and the compiler would actually get rid of the variable in its entirety
<rking> OK, I'm getting a bit bleary-eyed, but it looks like we have:
<rking> #define RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) \ type prot {return name args;}
<rking> #define RUBY_ALIAS_FUNCTION(prot, name, args) \ RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
<rking> No, that doesn't help, sorry.
<rking> OK, I have an idea... I'll try to use the pre-processor to answer this question.
<manveru> wait, you seriously want to embed ruby?
<rking> manveru: Why not?
<manveru> well, good luck :)
<rking> manveru: It's not easy?
workmad3 has joined #ruby-lang
<manveru> embedding ruby is never easy
<rking> That's surprising. I mean, I don't expect it to be a cakewalk, but I also don't expect it to be the kind of thing you immediately have to warn people against. =)
<manveru> yeah, guess i'm just comparing it to things like lua :)
<rking> Oh. Hrm.
<rking> I'd expect it to be like, Follow Cookbookish Thing, Make Changes, Done.
<rking> scientes: You might laugh.
<rking> scientes: typedef unsigned long VALUE;
<manveru> isn't that actually a pointer?
<manveru> weird
<rking> Perhaps it's being used that way -- this is the post-preprocessed output.
<rking> Maybe on this system somehow it is boiling down to an 'unsigned long' by that point.
<scientes> thats ruby.h
<scientes> I dont get it
<scientes> oh wait, thats silly
heftig has joined #ruby-lang
<rking> Yes, inside ruby.h that line is only run if SIZEOF_LONG == SIZEOF_VOIDP
<scientes> why don't they just call it THINGYMAJIG
<rking> So a VALUE is a void*
<scientes> or WHATCHAMACALLIT
<rking> scientes: Because when you make jokes in code, you 100% get sick of them, because you read them again and again.
<scientes> or there is a meaning, cause it's meaning changes due to the preprocessor
datanoise has joined #ruby-lang
<scientes> #if defined HAVE_UINTPTR_T && 0
<scientes> typedef uintptr_t VALUE;
<rking> "&& 0"
<rking> Where are you seeing that craziness?
<scientes> at the top of ruby.h
* scientes is getting more and more confused
<manveru> dead code then? :)
<rking> I'm impressed at how much changed between the two versions I'm looking at, 1.8.7 and 1.9.3
solars has joined #ruby-lang
<rking> Entire source tree is rearranged, it seems..
<scientes> well 1.9 is totally differn't
<scientes> rking, that was 1.9.3
<rking> scientes: If you look in the #elif below that it does the same thing as the 1.8.7 I pasted before: typedef unsigned long VALUE;
<scientes> vALUE is used all over the place
<scientes> rking, yes i greped that too
<rking> So that's settled. VALUE is a void* that happens to be typedef'd to uint, for some reason.
<rking> So what was the next question? Haha, I'm lost.
<scientes> yeah but does #elif SIZEOF_LONG == SIZEOF_VOIDP
<rking> Read it like English and don't worry about the implemtation of the symbols.
<scientes> and is that tmp thing still neccicary?
<rking> Perhaps the #error below will elaborate
<scientes> ahh gotcha
<rking> I don't know how I typed "implementation" so badly. =)
<scientes> so is sticking the return value in a VALUE have any meaning in the example in that post?
<rking> OK, yes, it does.
<rking> I was assuming (incorrectly) that VALUE was the actual return type of StringValuePtr(). But it isn't:
<rking> #define StringValuePtr(v) rb_string_value_ptr(&(v))
<rking> char* rb_string_value_ptr(volatile VALUE *ptr) { ... }
<rking> So basically we are assigning a char* to a void*
<scientes> ahh, zero-filling it
<rking> Which is a slight difference... as far as I know *'s are *'s
<rking> Nah
<rking> charSTAR to voidSTAR
<rking> Argh, darnit.
<workmad3> the type of the pointer changes the pointer arithmetic
<rking> Sorry... he's assigning the return of rb_iv_get() to VALUE tmp
<rking> workmad3: Aha, yes, good point. Oof. Pun not intended.
<scientes> which is a unsigned long
<rking> VALUE rb_iv_get(...) { ... }
<rking> SO, we're back to f(g()) === GsReturnType tmp = g(); f(tmp)
<rking> Maybe this post is messed up? I don't want to get so focused on taking it for gospel that we never get back to sanity.
<scientes> yeah but the length of char != length of unsigned long
<workmad3> sanity is overrated :)
<rking> scientes: I was being confusing when I said char* and void*.
<scientes> oh
<rking> Here is what we have, please forgive the several lines in a row:
<rking> VALUE tmp = rb_iv_get(self,"@source");
<rking> lpSourceName = (LPCTSTR)StringValuePtr(tmp);
<rking> Definition: VALUE rb_iv_get(VALUE obj, const char *name) { ... }
<scientes> you can get rid of the "(LPCTSTR)" part
<rking> So I absolutely see no point in the "tmp".
<rking> workmad3: Do you?
<rking> (BTW it didn't take as many lines as I though it would. In those 3 lines alone you can demonstrate the oddness of "tmp")
<workmad3> rking: I'd guess it's there purely to avoid a line '(LPCTSTRStringValuePtr(rb_iv_get(self, "@source"));'
<workmad3> (with an extra ')'... oops :) )
<scientes> workmad3, not if you read the post
apeiros_ has joined #ruby-lang
<rking> scientes: WAIT.
<workmad3> oh, is VALUE a void* yeah?
<rking> scientes: This post is from 2004. Perhaps at that point rb_iv_get was defined in such a way that it actually did matter.
<rking> workmad3: Yes. It's actually a uint, but it is used as a void*.
<workmad3> you can implicitly cast from any pointer to a void*, and from a void* to another pointer type, but you can't implicitly cast from one pointer type directly to another iirc
<scientes> ^^so abck to zero-filling
<rking> scientes: I motion to ignore this post (for now).
<rking> scientes: No zero-filling involved.
<rking> scientes: If anything, the pointer arithmetic thing workmad3 mentioned, but no zero-filling.
<workmad3> scientes: it doesn't alter the size of the pointer, just the interpretation
<rking> Yeah. =)
<rking> OK, let's put on the Serious Goggles and get to the bottom of this.
<rking> We are trying to translate pre-1.9.2 " STR2CSTR(RARRAY_PTR(orig_arg)[i])" to 1.9.3.
<workmad3> scientes: a pointer to a char is the same size as a pointer to a long (normally), but 'char* ptr; ptr + 1' is different to 'long* ptr; ptr + 1'
<workmad3> and I need to get to work... running late :/
<rking> workmad3: Thanks for the perspective. =)
<scientes> wierd....
<workmad3> scientes: C... nuff said :)
<scientes> OHHHH i got it
<rking> Not one thing about it is weird. =)
<rking> Yes.
<rking> Good.
<scientes> its cause char* ptr +1 you add 8
zmack has joined #ruby-lang
<rking> Exactly. 8 bits.
<scientes> and long* ptr + 1 you add le...
<scientes> yeah
<workmad3> scientes: yup, that's it :)
<rking> Now then, quoting from 1.8.7: #define STR2CSTR(x) rb_str2cstr((VALUE)(x),0)
<scientes> so pointers are kinda like structs
<workmad3> (although I believe normally the each pointer value addresses a byte in memory, so ptr + 1 with a char adds 1 to point to the next byte)
<rking> And rb_str2cstr() is non-trivial. Here comes: char* rb_str2cstr(str, len) VALUE str; long *len; { StringValue(str); if (len) *len = RSTRING(str)->len; else if (RTEST(ruby_verbose) && RSTRING(str)->len != strlen(RSTRING(str)->ptr)) { rb_warn("string contains \\0 character"); } return RSTRING(str)->ptr; }
<workmad3> but still, g2g, dave fun :)
<rking> scientes: Pointers are not like structs, no. =)
<scientes> well they are alot simpler :)
<rking> That's like saying, "Phone numbers are like phones. They are simpler."
<scientes> ok, sry
<rking> A pointer is a name, a label, an address, a location.
<scientes> its just that you add 1, but you are really adding something entirely differn't, cause you are counting by a differn't unit
<rking> A struct is a thing.
Joeysomo has joined #ruby-lang
ttilley has joined #ruby-lang
gnufied has joined #ruby-lang
esad has joined #ruby-lang
<rking> scientes: So that big old rb_str2cstr() is our new target. As you can see it does quite a bit.
Banistergalaxy has joined #ruby-lang
<scientes> it specifically says, dont use rb_str2cstr , use StringValue*()
<scientes> so that is probably a good hint
<rking> "Basically just replace STR2CSTR by StringValuePtr or define this macro."
<rking> Bam!
<rking> That's it.
Indian has joined #ruby-lang
<scientes> Symbol not found: _rb_str2cstr
<scientes> (copied from later in the post)
<scientes> as i said, rb_str2cstr is gone
<rking> Yes, hehe.. humorously enough, it comes down to a "VALUE tmp" thing again.
<rking> It actually refers directly to your previous ruby-talk post link.
<scientes> hmm
<rking> Wait, what about _rb_str2cstr? It shouldn't have anything to do with us at this point.
<scientes> thats just the same thing
<scientes> but using a _ prefix to avoid namespace issues, as its used internally
<rking> All we have to do is use StringValuePtr(), perhaps with that inexplicable "VALUE tmp" thing.
<rking> But we're not talking about it.
<rking> We're replacing STR2CSTR with StringValuePtr - where does rb_str2cstr come into play?
<scientes> s/ja/en/ doesn't work..
<erikh> wouldn't that be slower than allocating a new string anyhow?
<erikh> I mean, the string would have to be resized and so forth
<rking> erikh: Hrm?
<erikh> a RSTRING overwrite is what that call does, right?
<rking> erikh: Judging from the name alone, it's probably only returning the char* part of the Ruby String.
<erikh> oh, I misread. my bad.
<erikh> RSTRING(str)->ptr
<rking> Yes, the RSTRING... lol, yep, that.
<rking> I was typing that up exactly.
<erikh> :)
<rking> scientes: So we're good, right?
<scientes> i guess so
<scientes> i was just confused about all that tmp nonsense
<rking> Yes.
<rking> <rking> scientes: I motion to ignore this post (for now).
<rking> ^ Good advice. =)
<rking> If you have trouble for some reason we can try to incorporate "VALUE tmp", but at least at that point we should have enough information to figure out why it would be necessary.
* scientes needs to become more confident with C
<scientes> but ruby is kinda its own C as far as i can tell..
<erikh> ruby is it's own C as much as C is its own lisp
<erikh> you should lay off the analogies :P
<scientes> ok, just like the conflations
<scientes> :P
<erikh> they're different languages and each has things they're good at and things they're bad at
<erikh> learning that before someone hits you with a wall of language religion will do you some good
<scientes> no, i was talking about the C extension stuff, but whatever
<erikh> oh. those are mostly just macros and C functions.
<erikh> actually ruby's foreign function interface is one of the saner ones I've used.
<scientes> ok, good to know
<erikh> if you look at perl's XSUB or swig, you'll see some .. interesting examples
<scientes> #if 0
<scientes> } /* satisfy cc-mode */
<scientes> ahh the quirks of compatibility
<erikh> yeah. there's tons of that in there.
* scientes wishes people used #pragma once
PhilCK has joined #ruby-lang
ankurgel has joined #ruby-lang
<andrewhl> i have an array that looks something like this: [0, 1, 2, nil, 3, 6, nil, nil, 4, nil, 7, 35, nil]. I want to do something like this: array.index(array.max), but it chokes on the nils. How can I convert the nils to -1? Or is there another way I can extract the index of the largest number?
<andrewhl> I tried array.map! do |x| if x.nil? x = -1 end end, but that strangely converted all the nils to -1, and all the non-nils to nil
<andrewhl> (I'm choosing -1 but really 1 would work just as well. I just need the largest number and its index)
<ankurgel> arr.delete(nil)
<ankurgel> arr=[0,1,2,3,6,47,35]
<ankurgel> arr.max => 35
charper has quit [#ruby-lang]
<ankurgel> andrewhl: if you actually want -1 in place of nil, then: arr.collect{|x| (x.eql?(nil))?-1:x}
<andrewhl> ankurgel: yeah, the latter
<ankurgel> andrewhl: Choose any. Latter is doing exactly what you asked for. But, if you only wanted the maximum of an array which may/may-not contain nils, then arr.delete(nil).max is better.
<rippa> arr.compact.max
<rippa> is what I'd use
<rippa> ah, you need its index
<ddfreyne> arrrr
<ankurgel> and rippa does it again! I knew there was a method like that, just couldn't remember.
<rippa> well, same thing really
kitallis has joined #ruby-lang
<ankurgel> kitallis: ohai
<rippa> [1,nil,25,nil,nil,18].each_with_index.max_by {|n, i| n.to_i}
<rippa> #=> [25, 2]
<rippa> will choke on negative numbers because nils are transformed into 0s
<ankurgel> wow.
<ankurgel> And I was doing: arr=arr.collect{|x| (x.eql?(nil))?-1:x}; p arr.max; p arr.index(arr.max)
<ankurgel> tedious
dmathieu has joined #ruby-lang
rohit has joined #ruby-lang
gouthamvel has joined #ruby-lang
heftig has joined #ruby-lang
twelvechairs has joined #ruby-lang
ankurgel has quit [#ruby-lang]
batmanian has joined #ruby-lang
tjadc has joined #ruby-lang
scientes has joined #ruby-lang
bawer has joined #ruby-lang
workmad3 has joined #ruby-lang
yumike has joined #ruby-lang
rohit has joined #ruby-lang
tonesfrommars has joined #ruby-lang
tekin has joined #ruby-lang
gouthamvel has joined #ruby-lang
dragonkh has joined #ruby-lang
ankurgel has joined #ruby-lang
francisfish has joined #ruby-lang
morozovm has joined #ruby-lang
heftig has joined #ruby-lang
heftig has joined #ruby-lang
fvollero|gone has joined #ruby-lang
rohit has joined #ruby-lang
rking has joined #ruby-lang
hebz0rl has joined #ruby-lang
kain has joined #ruby-lang
toretore has joined #ruby-lang
Guedes has joined #ruby-lang
esad has joined #ruby-lang
ankurgel has joined #ruby-lang
gouthamvel has quit [#ruby-lang]
woollyams has joined #ruby-lang
fayimora has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
ttilley has joined #ruby-lang
ankurgel has joined #ruby-lang
Indian has joined #ruby-lang
futurechimp has joined #ruby-lang
srbartlett has joined #ruby-lang
arkkkk has joined #ruby-lang
rking has joined #ruby-lang
My_Hearing has joined #ruby-lang
msisk has joined #ruby-lang
jtoy has joined #ruby-lang
Paoc_ has joined #ruby-lang
esad has joined #ruby-lang
arkkkk has quit [#ruby-lang]
mark_locklear has joined #ruby-lang
mssola has joined #ruby-lang
kain has joined #ruby-lang
solars has joined #ruby-lang
IPGlider has joined #ruby-lang
ankurgel has joined #ruby-lang
Sailias has joined #ruby-lang
m3nd3s has joined #ruby-lang
apeiros_ has joined #ruby-lang
Dreamer3 has joined #ruby-lang
spectra has joined #ruby-lang
Dreamer3 has joined #ruby-lang
slyphon has joined #ruby-lang
dejongge has joined #ruby-lang
kain_ has joined #ruby-lang
lele|w has joined #ruby-lang
sei has joined #ruby-lang
malev has joined #ruby-lang
jekhokie has joined #ruby-lang
malev has joined #ruby-lang
<jekhokie> hello, I'm trying to create a rails view that has two select drop-downs that, when "submit" is clicked, will both store their selected values in an array to be passed to the server
kvirani has joined #ruby-lang
francisfish has joined #ruby-lang
dustacio has joined #ruby-lang
codewrangler has joined #ruby-lang
<darix> jekhokie: #RubyOnRails
jtoy has joined #ruby-lang
regius has joined #ruby-lang
<regius> Hi, I have a flex mock <-> ruby question. I have a block is .and_yields(value1, value2) the right way to make the block iterate over the values?
bglusman has joined #ruby-lang
<regius> the block looks like Find_mock.find do |path| puts path end
<regius> and i can't make it run multiple times
<regius> Any one used flexmock .and_yields?
ankurgel has joined #ruby-lang
ThatDudeGuy_ has joined #ruby-lang
mstratman has joined #ruby-lang
kain has joined #ruby-lang
robotmay has joined #ruby-lang
morozovm has joined #ruby-lang
lsegal has joined #ruby-lang
justinxreese has joined #ruby-lang
jensn has joined #ruby-lang
morozovm has joined #ruby-lang
Sailias has joined #ruby-lang
woollyams has joined #ruby-lang
esad has joined #ruby-lang
dv310p3r has joined #ruby-lang
bryancp has joined #ruby-lang
takaokouji has joined #ruby-lang
esad has joined #ruby-lang
enebo has joined #ruby-lang
kain_ has joined #ruby-lang
dous has joined #ruby-lang
kain__ has joined #ruby-lang
regius has joined #ruby-lang
jxie has joined #ruby-lang
kain has joined #ruby-lang
rohit has joined #ruby-lang
francisfish has joined #ruby-lang
JEG2 has joined #ruby-lang
imajes has joined #ruby-lang
fayimora has joined #ruby-lang
nofxx has joined #ruby-lang
outoftime has joined #ruby-lang
mssola has joined #ruby-lang
ankurgel has joined #ruby-lang
regius has joined #ruby-lang
denysonique has joined #ruby-lang
mssola has joined #ruby-lang
Touk has joined #ruby-lang
<Touk> puts "Hello everyone"
virunga has joined #ruby-lang
<Touk> Come on, that was original at least..
<apeiros_> IOError: not opened for writing
<injekt> ->e{}.(?????:??%%%)
<injekt> oops missed a +
<injekt> ->e{}.(?????:??+%%%)
<mistym> injekt: Ew.
<injekt> psh
<injekt> girls dig that stuff
<mistym> This one doesn't ;o
<Asher> i thought girls preferred APL
<injekt> heh
<robgleeson|mba> injekt: you should introduce me to these girls.
<injekt> robgleeson|mba: come down here and I will ;D
<robgleeson|mba> ;p
<injekt> actually I'm up your way in a couple months
<robgleeson|mba> yeah?
<robgleeson|mba> what for?
<injekt> a stag do
<robgleeson|mba> hah nice one.
<robgleeson|mba> what part?
<injekt> can't remember exactly, only got told last night
<robgleeson|mba> more reason to remember :@
<injekt> haha yeah :S
<injekt> they weren't specific and I wasn't listening much
<injekt> I'll find out
<robgleeson|mba> beer ears.
<robgleeson|mba> cool
<injekt> ;D
<injekt> on another note, pusherapp is pretty neat
andrewhl has joined #ruby-lang
<robgleeson|mba> using that at allur?
<apeiros_> injekt: where's "down here"?
<injekt> not yet, but I have a few different options to choose from and starting implementations soon
<injekt> apeiros_: southern UK
<apeiros_> close to london?
<injekt> pusher looks the most polished atm
<injekt> apeiros_: about an hours drive
<apeiros_> I might, next year
<injekt> cool!
<injekt> I might be in canada then, but hey I might be here
<apeiros_> even more likely if you have some awesome ruby or rails conf :)
<injekt> :)
<apeiros_> you go to canada for the full year?
<injekt> na but my startup is canada based
<injekt> so I plan on heading there for a while, although haven't decided yet
<apeiros_> I see
<apeiros_> hah, the "Oracle SQL" book by O'Reilly features a scorpion as the picture on its cover. how very fitting…
takaokou_ has joined #ruby-lang
<Asher> their permatrip bonobo is the best
<Touk> My employer just told me to develop a script for him using Python (quite complex, many mathematic stuff here), and I answered him that I would prefer to do it in Ruby. He's now asking me why. Since he's a very good programmer and my only answer would be "because I prefer Ruby's syntax", is there any technical advantage using Ruby to Python ? Thanks for saving my job :)
slimfit has joined #ruby-lang
headius has joined #ruby-lang
<injekt> what's wrong with 'because I prefer ruby's syntax?'
<injekt> why isn't that enough? you're writing it
<andrewvos> Yeah fuck your boss
<Touk> Isn't it a bit light ? :/
<injekt> what?
<Touk> He'll tell me that there are more libraries in Python etc
<Touk> common arguments...
<injekt> are there?
Swimming_Bird has joined #ruby-lang
<Touk> I dunno, but he'll certainly believe it
<apeiros_> for math stuff, there's actually quite a bit for python
<injekt> yup there is
<injekt> it beats ruby hands down mostly
<injekt> but still
<mistym> Yeah, Python is pretty well-entrenched in scientific applications.
<injekt> those are only useful if you're using them
<Touk> When I said complex, I meant that I have to programm the algorithms
<Touk> their goal is complex
gsav has joined #ruby-lang
<Touk> but it's basically array manipuation
<injekt> the thing is, you might not have to with some of the python stuff that's available to you, to be honest I dont know why you are your boss are having that conversation if you're the only one writing this thing
<injekt> I would tell him to fuck off and quit my job
<injekt> but hey that's me
<Touk> Because people have prejudices, and prejudices are strong
<injekt> is it as strong as your reasoning to use ruby?
<Touk> Last time, he told me to write a programm in C++ over Java because "JVM is unsecured"
<injekt> eh
<Touk> who in this world can use JVM's flaws ?
<injekt> he's a troll
<Touk> seriously ?
<injekt> thank you for reminding me why I dont work for anyone
<Touk> I'm working for my country's government -_-
<injekt> (at least, dont have a boss/manager)
<Touk> So I'll tell him I will be more productive using Ruby over Python
rippa has joined #ruby-lang
<injekt> Touk: why dont you just write it in whatever you want to write it in and tell him it works?
Joeysomo has joined #ruby-lang
<Touk> time is money, he'll accepet that
<Touk> I hope
<Touk> injekt: Military institution, you don't say what you think :D
<mistym> Touk: Guess the other question is, will someone else have to maintain this later? If so, are there more pythonistas than rubyists in your shop?
<injekt> ^
<injekt> only reason I would do it in python, if many other people were to maintain it and they only know python
<Touk> mistym: Nop, it will be coded, certified, and then used as a basis of many things
<Touk> People won't touch it anymore
<Asher> only reason i'd do it in python is i wouldn't...
<injekt> then he's wasting time arguing between ruby and python :)
<Touk> I think he just doesn't know Ruby and looked a bit on Google seeing people complaining
<mistym> Maaan, does he not know the internet?
<mistym> People complain about *everything*
<Touk> He's a military, he barely knows what programming is
<Touk> he just have prejudices
<Touk> but he's still my boss -_-
<robgleeson|mba> you just said he is a very good programmer :p
<injekt> then he has no place in this decision
<robgleeson|mba> "Since he's a very good programmer …"
<Touk> robgleeson|mba: Yeah, he's a very good programmer, he knows everything that's being said on languages
<Touk> robgleeson|mba: But he can't code a shit
<injekt> :S
<mistym> I think you have a different definition of "very good programmer" than I do.
<Touk> robgleeson|mba: To say it concretely, he has some very good knowledge into programming theory, but none in application
<injekt> a good programmer can code a shit
<injekt> ok im using pusher this stuff is awesome
<Touk> injekt: I'll use ur arguments injekt, brb :D
<injekt> what? "because fuck you, I'm using ruby!" ?
<injekt> robgleeson|mba: does ga outsource any work?
poupoupoupoupo has joined #ruby-lang
<robgleeson|mba> i think we have a few contracters but they're looking for permanent fixtures right now afaik.
<injekt> word
Dreamer3 has joined #ruby-lang
<Touk> Thank injekt, it partly worked :)
Banistergalaxy has joined #ruby-lang
kvirani has joined #ruby-lang
outoftime has joined #ruby-lang
drbrain has joined #ruby-lang
havenn has joined #ruby-lang
tommyvyo has joined #ruby-lang
datanoise has joined #ruby-lang
sandbags has joined #ruby-lang
urbanmonk has joined #ruby-lang
Radium has joined #ruby-lang
JEG2 has joined #ruby-lang
phaedrix has joined #ruby-lang
vesan has joined #ruby-lang
m3nd3s has joined #ruby-lang
datanoise has joined #ruby-lang
apeiros has joined #ruby-lang
<imperator> ga?
* imperator wakes up
regius has joined #ruby-lang
<any-key>
ankurgel has joined #ruby-lang
<any-key> is there a good way to read X number of bytes from an IO object?
<any-key> there's getbyte, but nothing that reads a certain number of bytes
rue has joined #ruby-lang
<injekt> any-key: #read
<any-key> hah >.<
<any-key> thanks
<any-key> aaaand all of a sudden things start working
<injekt> :)
t has joined #ruby-lang
heftig has joined #ruby-lang
m3nd3s has joined #ruby-lang
phipes has joined #ruby-lang
<erikh> imperator: hey, do you have a solaris box and don't mind testing something?
<erikh> ISTR you testing sys/proctable on it, which is why I'm asking.
<imperator> erikh, got a solaris vm, gimme a sec to fire it up
<imperator> erikh, want to ask your advice about something later too
butchanton has joined #ruby-lang
<shevy> breathe slowly!
fayimora has joined #ruby-lang
butchanton has quit [#ruby-lang]
thrcka has joined #ruby-lang
butchanton has joined #ruby-lang
<imperator> erikh, ok, it's up; whaddya need?
slimfit has joined #ruby-lang
scampbell has joined #ruby-lang
<erikh> imperator: sec
<erikh> can you run that on it? it's an interface dumper.
<imperator> erikh, no getifaddrs on solaris apparently, at least not in libc
mrsolo has joined #ruby-lang
<imperator> let me check if it's in another lib
<erikh> ah crap
apeiros_ has joined #ruby-lang
<imperator> minor bug on line 106, btw
Jay_Levitt has joined #ruby-lang
<erikh> nah that's intentional
<erikh> the struct on linux is a mess
solars has joined #ruby-lang
<imperator> ok
<erikh> basically there's no sa_len on linux so it uses macros to do everything
<erikh> and sizeof() calcs, neither of which are available to FFI
<imperator> you can get sizeof via mkmf-lite :)
<erikh> yeah but I need a compiler for that, right?
<imperator> true
<erikh> I'm going to try and pitch this to the chef folks as a compiler free option
<erikh> big deal for them because sysadmins hate compilers
<imperator> wonder if it could implemented in pure ruby using the socket lib?
<erikh> possibly, but there's a lot more data there
<erikh> oh, no, you may be right
<erikh> oh this isn't a complete implementation
<imperator> hm, found something that uses ioctl + SIOCGIFCON
<imperator> F
<erikh> err, nm, you're right, I think this part can be done
<erikh> the getnameinfo() bit probably can't without a lot of resolver mess though
<imperator> lemme try this with pure ruby on solaris
<erikh> ok
<erikh> ha, pitched me that mackeeper software
<erikh> the virusy stuff.
<imperator> oops
<imperator> there's actually an implementation in Unix Network Programming
<erikh> oh, neat.
Swimming_Bird has joined #ruby-lang
m3nd3s has joined #ruby-lang
io_syl has joined #ruby-lang
bryancp has joined #ruby-lang
turboladen has joined #ruby-lang
nofxx has joined #ruby-lang
gouthamvel has joined #ruby-lang
<imperator> well, dang, SIOCGIFCONF doesn't seem to be defined by fcntl
<erikh> patch time
zmack has joined #ruby-lang
<erikh> imperator: hey, what was your question?
<erikh> sorry to be impatient, but I need to bail; I'll be back in a few hours most likely.
<erikh> if you want to shoot me an email, erik@hollensbe.org
<imperator> erikh, alright, talk to you later
RickHull1 has joined #ruby-lang
hahuang65 has joined #ruby-lang
Carnage\ has joined #ruby-lang
gouthamvel has quit [#ruby-lang]
achiu has joined #ruby-lang
m3nd3s_ has joined #ruby-lang
dejongge has joined #ruby-lang
jtoy has joined #ruby-lang
publicvoid has joined #ruby-lang
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
gnufied has joined #ruby-lang
francisfish has joined #ruby-lang
kitallis has joined #ruby-lang
regius has joined #ruby-lang
kvirani has joined #ruby-lang
dejongge1 has joined #ruby-lang
SuperTaz_work has joined #ruby-lang
vesan has joined #ruby-lang
crudson has joined #ruby-lang
ericmuyser has joined #ruby-lang
Yu\2 has joined #ruby-lang
rue has joined #ruby-lang
tjadc has joined #ruby-lang
bryancp has joined #ruby-lang
postmodern has joined #ruby-lang
ddfreyne has joined #ruby-lang
SuperTaz_work has joined #ruby-lang
rushanuk has joined #ruby-lang
havenn has joined #ruby-lang
towski has joined #ruby-lang
rushanuk has joined #ruby-lang
savage- has joined #ruby-lang
VladGh has joined #ruby-lang
Jake232 has joined #ruby-lang
<Jake232> How can I get a ruby Time object
<Jake232> from a timestamp?
<Jake232> Maybe I'm mising something, I just can't find the function
<shevy> tried .parse ?
crudson has quit [#ruby-lang]
<shevy> and how does your timestamp look
<Jake232> 1333477526
<Jake232> and I'll try parse
<shevy> huh
<shevy> what is this
<shevy> :)
<shevy> just numbers?
<Jake232> Yes
<shevy> hmmmmmmm
<Jake232> It's the result of a Time.something.to_i
<shevy> this as is seems not valid
<Jake232> from a different system
<shevy> Date.parse("1333477526") # ArgumentError: invalid date
<shevy> yah no idea, sorry
<Jake232> Aha, got it.
<Jake232> Time.at(1333477526)
<shevy> cool
<any-key> So, say I have "\xA3" and I want to get the integer value of it
* shevy presses any-key
<any-key> normally I'd do .ord, but unfortunately A3 isn't a UTF-8 byte sequence
<any-key> anyone have any ideas?
<any-key> I basically need to convert "\xA3" to 163
<any-key> nvmd
* shevy presses any-key harder!!!
<any-key> "\xA3".bytes.to_a.first
gsav has joined #ruby-lang
francisfish has joined #ruby-lang
indeterminate has joined #ruby-lang
esad has joined #ruby-lang
wyhaines has joined #ruby-lang
<drbrain> "\xA3".unpack "C"
slyphon has joined #ruby-lang
<drbrain> "\xA3".force_encoding(Encoding::BINARY).ord
ElemarJR has joined #ruby-lang
francisfish has joined #ruby-lang
<any-key> drbrain: thanks, I like the unpack one
<any-key> alternatively my previous solution could be shortened to "\xA3".bytes.first
<drbrain> usually when you're working with bytes, unpack is the tool you want
<any-key> it's true, I use pack several times in this with "C"
<necromancer> is there a way to turn off the backtrace when Turn finds a skipped test? it's really annoying and useless...
<lianj> unpack return an array though
elemarjr has joined #ruby-lang
rolfb has joined #ruby-lang
jarred has joined #ruby-lang
toretore has joined #ruby-lang
<imperator> necromancer, config option maybe? not sure, haven't used Turn in a long time
<necromancer> imperator: well i'm using Rails, can i do this from within config/initializers/backtrace_silencers.rb somehow? when i add turn and minitest to the list of silenced libs it doesn't seem to work
shtirlic has joined #ruby-lang
curtism has joined #ruby-lang
<imperator> i'm afraid i don't know that one right off
<drbrain> necromancer: minitest does not print backtraces for skipped tests by default
<imperator> i see there's a "trace" option
<any-key> okay, another stupid byte question: I have the string "\x04\x90" and I'm trying to turn it into an 8 bit integer
<necromancer> drbrain: right, i think it's Turn doing it
<any-key> unpack("C") does it for each byte rather than taking two bytes at a time
<necromancer> imperator: i saw that but i still want backtraces for ERRORs, just not SKIPs...
<imperator> any-key, unpack("C*")
<necromancer> i don't even know why you'd want a backtrace for SKIP anyway. i can't think of a single reason why one would want to see the same backtrace 50 times if they skip 50 tests...
bryancp has joined #ruby-lang
<drbrain> any-key: you can't turn 0x0490 into an 8 bit integer
<any-key> imperator: I get [4,144], not a single integer
<drbrain> any-key: it only fits in 16 bits
l0st1 has joined #ruby-lang
<any-key> ah shit, you're right
<ankurgel> Isn't this how I should check for condition there? -> http://i.imgur.com/S1m10.png ?
robbyoconnor has joined #ruby-lang
<imperator> turn requires minitest now? huh
<ankurgel> #pack, #unpack. I need to practice that as well.
<any-key> my bit banging skills are a bit out of date
robbyoconnor has joined #ruby-lang
outoftime has joined #ruby-lang
<imperator> and it bombs out on me with a syntax error, wow
futurechimp has joined #ruby-lang
<imperator> necromancer, what version you using?
<imperator> I'm getting a syntax error, pretty_reporter.rb, line 134
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
<imperator> def prettify(message=nil, raised) # => can't do that
<imperator> not even in 1.9 afaik
<drbrain> ankurgel: "in the each block" is your clue
<drbrain> imperator: yes in 1.9
tonesfrommars has joined #ruby-lang
<imperator> drbrain, just tried it in irb, gave me a syntax error
savage- has joined #ruby-lang
<drbrain> never trust irb for syntax ☹
<imperator> oh, nm, i had a semicolon in there
<imperator> so, turn only works on 1.9, jeesh
<imperator> needs to update his gemspec then
<imperator> oh, dear lord, wtf is that?
* imperator looked at the turn gemspec
<Defusal> reasonable effort to efficiently implement directory watching if you want to store each paths mtime and size in a database
<imperator> Defusal, is that a question?
<Defusal> no, a statement :P
<imperator> there are some polling libs out there
<Defusal> got it down to 65ms to initially gather 2849 nested paths stats and insert them, thats the most time consuming part
<Defusal> but after that, it recursively checks, so it wont go deeper than it needs to
<Defusal> not for watching in realtime, i use inotify to have the kernel fire events for that imperator
<imperator> i'm curious why you would want to do such a thing; i would think that would balloon rather quickly
<Defusal> this is for when inotify events are stopped and started again
<Defusal> which happens for various reasons, as well as when the modules watching files are reloaded
<Defusal> so i can't afford to miss events and lose state
<necromancer> imperator: 0.9.3
rue has joined #ruby-lang
<necromancer> imperator: there's nothing weird about that syntax
andrewhl has joined #ruby-lang
<imperator> necromancer, it doesn't work in 1.8 :)
<necromancer> imperator: oh can you not set default values in the method definition in 1.8? i can't remember, it's been so long...
* drbrain chants "1.8 is dead! long live 1.9!"
<imperator> def foo(x, y=1) is legal; def foo(x=1, y) is not
<necromancer> oh
<necromancer> imperator: the code i'm looking at (HEAD from github) is def prettify(raised, message=nil)
<necromancer> so it's valid
<necromancer> in 1.8
<necromancer> i had no idea the order mattered like that
<imperator> looks like he flipped it in 0.9.4; why, i have no idea
rking has joined #ruby-lang
<imperator> necromancer: https://github.com/TwP/turn/issues/89
ahf has joined #ruby-lang
H2H has joined #ruby-lang
boxmo has joined #ruby-lang
hahuang65 has joined #ruby-lang
gouthamvel has joined #ruby-lang
gouthamvel has quit [#ruby-lang]
Faris has joined #ruby-lang
bawer has joined #ruby-lang
bradland has joined #ruby-lang
<bradland> i'm working with a gem named Sprinkle, and have hit a wall (problem I can't get my head around); i did a brief write up and posted a repo to github: https://github.com/bradland/sprinkle-package-argument-test
<bradland> hoping someone has a few spare moments to have a look
r0bby has joined #ruby-lang
benanne has joined #ruby-lang
justinmcp has joined #ruby-lang
voker57 has joined #ruby-lang
voker57 has joined #ruby-lang
rking has joined #ruby-lang
srbartlett has joined #ruby-lang
msisk has joined #ruby-lang
youngin has joined #ruby-lang
<youngin> How do I add a Ruby script within a screen to my crontab? Simply like this?
<youngin> */5 * * * * screen /home/youngblood/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /home/youngblood/myscript.rb
workmad3 has joined #ruby-lang
<burgestrand> bradland: that’s not brief :p
<bradland> burgestrand: haha :)
yxhuvud has joined #ruby-lang
<bradland> i'm giving a masters course in asking questions later :)
msisk has joined #ruby-lang
rking has joined #ruby-lang
<bradland> burgestrand: i think i'm getting my head around it. in simplest terms: the example they provide doesn't work because Policy#requires does nothing with the second argument (options={}).
<burgestrand> bradland: looks like it
ironcamel has joined #ruby-lang
<ironcamel> what is the proper way to define a function with braces: def foo() { puts 'hello' }
bryancp has joined #ruby-lang
bawer has joined #ruby-lang
<manveru> define_method(:foo){ puts 'hello' }
<ironcamel> ah, so i guess the block syntax is the way to go
chimkan has joined #ruby-lang
<ironcamel> def .. end
<ironcamel> someone told me ruby supports { ... } style blocks, i guess technically they were right
<ironcamel> what is the nicest way to define a function on a single line?
Radium has joined #ruby-lang
pw_ has joined #ruby-lang
<ironcamel> this seems to work: def foo() puts 'hello' end
<_tca> you should try not to
Indian has joined #ruby-lang
<ironcamel> really?
<ironcamel> so 3 line minimum
<drbrain> really
<drbrain> blocks are not the same as methods
<ironcamel> am i using the wrong terminology?
<ironcamel> i just mean the body of a function definition
<_tca> ironcamel: function != method
<ironcamel> ok ....
<burgestrand> You’re all very… concise
<ironcamel> i was talking about a function
<ironcamel> yes, very precise
<burgestrand> ironcamel: what you call functions, in ruby we call methods
srbartle_ has joined #ruby-lang
<ironcamel> ok
<ironcamel> the body of a method definition
<Mon_Ouie> Ruby doesn't really have functions, it has methods and procs (anonymous functions, if you will)
<Asher> presumably the difference is that methods are on objects whereas functions are anonymous
<ironcamel> should always span 3 lines
<burgestrand> ironcamel: blocks in ruby are a special kind of thing, you can write them using { … } or do … end, but they are not related to methods, or even "code blocks" from many other languages
<ironcamel> so is there some default class all methods belong to?
<Mon_Ouie> burgestrand: I would do more concise :p "what do you think of this syntax? def do_stuff; @foo * 3; end"
<ironcamel> burgestrand: ruby blocks are basically closures right?
<Asher> methods are the only thing in ruby that is not an object on its own - tho if you inquire after it you will get an object describing it
* necromancer says function all the time when he refers to a method. so fuck you. ;)
<_tca> yes ironcamel
<burgestrand> ironcamel: yes
<necromancer> if you really want to call it what it is call it a message
<necromancer> because that's what it is
<burgestrand> ironcamel: and as far as default class, you always have a current "self", your current context if you will
<ironcamel> and the ruby style police say all method definitions should span 3 lines at least?
<necromancer> #ruby-lang.send :suck_it
<Asher> necromancer - no no a message is what invokes it ;)
<mistym> Otherwise you go to ruby style jail.
<necromancer> Asher: ah that's true
<burgestrand> ironcamel: at the very topmost scope, this "self" is a special object called "main", and it’s an instance of "Object"
<ironcamel> hmmm, main.foo() doesn't seem to work
<Asher> ironcamel - the 3 line bit is silly just a conceptual guideline for the idea that methods should generally be small
<burgestrand> ironcamel: you should be getting an error about a private method
wyhaines_ has joined #ruby-lang
<ironcamel> yes
<necromancer> ironcamel: does main = MainOrWhateverYourClassIsCalledBecauseYouDidntTellMe.new
<necromancer> ?
<burgestrand> ironcamel: ruby’s private methods cannot be called with an explicit receiver
<ironcamel> undefined local variable or method `main' for main:Object (NameError)
<burgestrand> ironcamel: hehe, type "self"
<necromancer> oh yeah :)
<burgestrand> ironcamel: not main :)
wyhaine__ has joined #ruby-lang
<ironcamel> private method `foo' called for main:Object (NoMethodError)
<necromancer> what do you think this is, JAVA LAND?!?
<burgestrand> ironcamel: there we go ;)
<necromancer> aint no mains in ruby land
<ironcamel> burgestrand: said there was
<burgestrand> ironcamel: try self.send(:foo)
<burgestrand> ironcamel: send in ruby ignores visibility, so you can force-call a private method of anything if you want to
<ironcamel> that works
<burgestrand> ironcamel: you can also write: public :foo
<burgestrand> and then you can do self.foo
<ironcamel> public :foo() ?
<burgestrand> ironcamel: no, public :foo
<burgestrand> ironcamel: or public "foo" might also work
<ironcamel> in the defintion?
<burgestrand> ironcamel: no, on a line of its own :)
<ironcamel> or after the definition of the method
<ironcamel> ok
<Mon_Ouie> public is a method that expects a method name
<burgestrand> ironcamel: public/private/protected are methods in ruby too
<burgestrand> so you can call them like methods
<Mon_Ouie> And it makes that method public (or those methods if there are more than one)
<mistym> ironcamel: :foo is a symbol (a unique string), which often stands in as a method name identifier when you're calling methods that take methods as args.
<ironcamel> yeah
<Mon_Ouie> There's an alternative syntax: you can just do "public" on its own line, and any subsequently defined method will be public
<ironcamel> how do i say foo is public in the declration of foo?
<burgestrand> lots of things in very short time
<burgestrand> :d
<mistym> public is default, unless you've written "private" on its own line somewhere above it.
<burgestrand> you don’t do it in the declaration, you either say "public :foo", or before you define foo you say just "public", and all methods defined after that point will be public by default
<burgestrand> (it works the same for "private" and "protected")
<ironcamel> oh, like c++
<burgestrand> yeah, kind of!
<ironcamel> default is private?
<ironcamel> sorry if someone already answered that
<burgestrand> ironcamel: default is actually public, except for inside the main object, topmost scope
<ironcamel> oohhh
<ironcamel> ok
<ironcamel> i wonder why they did that
<burgestrand> some things make more sense than others at first glance, does not necessarily make it bad :)
<Mon_Ouie> Because when you define a method at top-level, it's usually some kind of helper method
<Mon_Ouie> i.e. it ignores self, it doesn't really makes sense to call it on a specific object
<Mon_Ouie> (private and protected aren't exactly the same as in C++, either)
<ironcamel> yeah
H2H has joined #ruby-lang
musl has joined #ruby-lang
rushanuk has quit [#ruby-lang]
rking has joined #ruby-lang
dejongge has joined #ruby-lang
s0ber has joined #ruby-lang
y3llow_ has joined #ruby-lang
fgomez has joined #ruby-lang
kain has joined #ruby-lang
y3llow has joined #ruby-lang
butchanton has joined #ruby-lang
y3llow has joined #ruby-lang
Brainix has joined #ruby-lang
justinmcp has joined #ruby-lang
gouthamvel has joined #ruby-lang
gouthamvel has quit [#ruby-lang]
scientes has joined #ruby-lang
<ironcamel> addresses = server.addresses[:public].reject {|addr| addr.version != TEST_IP_TYPE}
<ironcamel> doesn't that look like a double negative to you guys?
<ironcamel> wouldn't it be better to use the opposite of 'reject'
<ironcamel> and check for == instead of !=
<imperator> depends, do you only want TEST_IP_TYPE ?
<ironcamel> yes
<ironcamel> imperator: you are saying logically what i was saying was wrong?
<imperator> server.addresses[:public].map{ |addr| addr.version == TEST_IP_TYPE }
<ironcamel> are you sure it is map?
<ironcamel> is there an array.grep?
<dominikh> yeah, I'd rather expect select :P
andrewhl has joined #ruby-lang
<ironcamel> addrs.select ?
<imperator> yes, select
phipes has quit [#ruby-lang]
<imperator> MY BAD
<ironcamel> how do i see the documentation for the array methods from the command line??
<Mon_Ouie> ri Array (or ri Array#some_method)
<ironcamel> thanks
<Mon_Ouie> You may need to install the documentation data though (depends on how you installed ruby itself)
fayimora has joined #ruby-lang
phipes has joined #ruby-lang
phipes has quit [#ruby-lang]
postmodern has joined #ruby-lang
RickHull has joined #ruby-lang
malev_ has joined #ruby-lang
havenn has joined #ruby-lang
kain has joined #ruby-lang
crudson has joined #ruby-lang
SpitfireWP has joined #ruby-lang
kain_ has joined #ruby-lang
ankurgel has quit [#ruby-lang]
robbyoconnor has joined #ruby-lang
crudson has quit [#ruby-lang]
thone has joined #ruby-lang
robbyoconnor has joined #ruby-lang
Radium has joined #ruby-lang
My_Hearing has joined #ruby-lang
fgomez has joined #ruby-lang
kain has joined #ruby-lang
td123 has joined #ruby-lang
bglusman has joined #ruby-lang
slimfit has joined #ruby-lang
twelvechairs has joined #ruby-lang
td123 has joined #ruby-lang
Aristata has joined #ruby-lang
Aristata has quit [#ruby-lang]
slimfit has joined #ruby-lang
msisk has joined #ruby-lang
codewrangler has joined #ruby-lang
bglusman has joined #ruby-lang
io_syl has joined #ruby-lang
Carnage\ has joined #ruby-lang
woollyams has joined #ruby-lang
Boohbah has joined #ruby-lang
fayimora_ has joined #ruby-lang
gregmoreno has joined #ruby-lang
slimfit has joined #ruby-lang
fgomez has joined #ruby-lang
Swimming_Bird has joined #ruby-lang
PhilCK has quit [#ruby-lang]
wyhaines has joined #ruby-lang
<matti> TODO: Write usage instructions here
<matti> ...
<matti> :<
<matti> erikh: Nice lib ;]
<erikh> I just pushed it about 20 minutes ago
<erikh> it's not release-ready yet
<rue> Wonder if there's a gem called TMI yet
<erikh> sorry
<erikh> well there's ohai and facter
<matti> Ohai uses external 3rd party for such detaled information.
<matti> Facter uses bunch of weird code ;]
<matti> IIRC, this 3rd party is called SIGAR
slyphon has joined #ruby-lang
nofxxx has joined #ruby-lang
<imperator> erikh, looking...
* imperator was afk there
<imperator> some duplication with some of my sys-* stuff
<erikh> matti: ohai only uses SIGAR in some circumstances
<erikh> namely, if it's installed.
<erikh> (and it usually isn't)
<imperator> erikh, does Socket.gethostname not work well enough?
<erikh> imperator: yeah, probably
<erikh> this was more of a way for me to learn some calls than anything
charlenopires has joined #ruby-lang
<erikh> at least originally.
<imperator> that was my excuse for sys-host :)
<matti> erikh: Oh, I did not know that.
<imperator> (learning C extensions back in the day)
<matti> erikh: AFAIK, it used be a dependency.
<erikh> I'm probably going to extract the getifaddrs stuff and push it to the chef people
<erikh> since with FFI the "I need a compiler" argument goes away
<matti> :)
<imperator> erikh, if you can figure out how to make it work with ioctl it would be more cross-platform
<imperator> on windows it would be [insert .25 to continue]
crudson has joined #ruby-lang
<erikh> heh
<erikh> imperator: I don't possess the posix-fu to make that happen
Weems has joined #ruby-lang
<erikh> I'm fairly green with C really
<imperator> well at least you're trying; puppet was using system calls last i checked
<imperator> if (FFILib.getifaddrs(cur) == -1) # => hey man, this ain't C, no parens required ;)
<erikh> feh
<imperator> FEH!
slyphon has joined #ruby-lang
<erikh> yeah, ohai scrapes iproute2 right now
<imperator> is that a traceroute program?
dejongge has joined #ruby-lang
imajes has joined #ruby-lang
<erikh> nah, it's like a less painful version of ifconfig and netstat
<erikh> err, freebsd netstat, not linux netstat
Axsuul has joined #ruby-lang
fgomez has joined #ruby-lang
gregmoreno has joined #ruby-lang
kain has joined #ruby-lang
tenderlove has joined #ruby-lang
codewrangler has joined #ruby-lang
charlenopires has joined #ruby-lang
dv310p3r has joined #ruby-lang
fayimora has joined #ruby-lang