coryf has quit [Remote host closed the connection]
agile has joined #ruby-lang
workmad3 has quit [Ping timeout: 244 seconds]
mrsolo has quit [Quit: Leaving]
Hakon has joined #ruby-lang
sandbags has quit [Remote host closed the connection]
billyoc has quit [Ping timeout: 272 seconds]
sandbags has joined #ruby-lang
sandbags has quit [Changing host]
sandbags has joined #ruby-lang
workmad3 has joined #ruby-lang
thedarkone_ has quit [Quit: thedarkone_]
sandbags has quit [Ping timeout: 246 seconds]
<jaimef>
["1d", "2h", "3m", "4s"].each {|x| x.gsub(/dhms/) } # not working. trying to remove the non-numeric compnents of each string.
programR has quit [Quit: Leaving]
<Erlkoenig>
x.gsub(/[dhms]/)
<Erlkoenig>
or maybe x.gsub(/[dhms]/, "")
<jaimef>
yeah I have [] in my real one. missed pasted
<Erlkoenig>
or x.gsub(/[^[digit]]/, "")
<Erlkoenig>
ermm, x.gsub(/[^[:digit:]]/, "")
sepp2k1 has quit [Read error: Connection reset by peer]
<jaimef>
map works
<Erlkoenig>
ah of course... didn't see the each :D
<Erlkoenig>
gsub! would also work, by modifying the original array
tenderlove has joined #ruby-lang
<jaimef>
yeah long week
tenderlove has quit [Remote host closed the connection]
workmad3 has quit [Ping timeout: 246 seconds]
replore has joined #ruby-lang
drumond19 has quit [Ping timeout: 246 seconds]
seanstickle has quit [Quit: seanstickle]
dmwuw has joined #ruby-lang
lsegal has joined #ruby-lang
gurps has quit [Quit: bye]
replore has quit [Remote host closed the connection]
Jake232 has quit [Quit: Computer has gone to sleep.]
towski has quit [Remote host closed the connection]
Madis has quit [Quit: ChatZilla 0.9.88.2 [Firefox 11.0/20120313180949]]
mistym has quit [Remote host closed the connection]
havenn has quit [Ping timeout: 245 seconds]
gurps has joined #ruby-lang
RegEchse has quit [Quit: <3 WeeChat (v0.3.9-dev)]
havenn has joined #ruby-lang
cirenyc has joined #ruby-lang
<cirenyc>
How can I verify that a class has extended a module?
kain has quit [Remote host closed the connection]
kain has joined #ruby-lang
<Erlkoenig>
you mean whether a specific instance has included a module? myinstance.is_a?(ModuleName)
mistym has joined #ruby-lang
mistym has quit [Changing host]
mistym has joined #ruby-lang
codesturgeon has joined #ruby-lang
codesturgeon has quit [Client Quit]
sush24 has joined #ruby-lang
anannie has quit [Remote host closed the connection]
<havenn>
cirenyc: This is somewhat convoluted (there may be a much more elegant way to do it, just not one I know >.>): https://gist.github.com/3671212
<cirenyc>
Erlkoenig: That worked.
<cirenyc>
havenn: i'll take a look, thanks
<havenn>
cirenyc: ^^Erlkoenig
<havenn>
cirenyc: I'm not to be trusted!
sush24 has quit [Quit: This computer has gone to sleep]
ohsix has quit [Read error: Connection reset by peer]
chessguy_ has joined #ruby-lang
chessguy_ has quit [Remote host closed the connection]
chessguy_ has joined #ruby-lang
^sandbags^ has joined #ruby-lang
^sandbags^ has quit [Changing host]
^sandbags^ has joined #ruby-lang
havenn has quit [Remote host closed the connection]
sandbags_ has joined #ruby-lang
sandbag__ has joined #ruby-lang
coryf has joined #ruby-lang
justinmcp has joined #ruby-lang
^sandbags^ has quit [Ping timeout: 246 seconds]
Hakon has quit [Quit: Leaving...]
sandbags_ has quit [Ping timeout: 246 seconds]
kvirani has quit [Remote host closed the connection]
kvirani has joined #ruby-lang
arooni-mobile has joined #ruby-lang
arooni-mobile has quit [Max SendQ exceeded]
arooni-mobile has joined #ruby-lang
Hakon has joined #ruby-lang
kvirani has quit [Ping timeout: 244 seconds]
arooni-mobile has quit [Max SendQ exceeded]
sush24 has joined #ruby-lang
arooni-mobile has joined #ruby-lang
arooni-mobile has quit [Max SendQ exceeded]
chessguy_ has quit [Remote host closed the connection]
arooni-mobile has joined #ruby-lang
sush24 has quit [Quit: This computer has gone to sleep]
arooni-mobile has quit [Max SendQ exceeded]
alvaro_o has quit [Quit: Ex-Chat]
arooni-mobile has joined #ruby-lang
arooni-mobile has quit [Max SendQ exceeded]
arooni-mobile has joined #ruby-lang
arooni-mobile has quit [Max SendQ exceeded]
arooni-mobile has joined #ruby-lang
arooni-mobile has quit [Max SendQ exceeded]
igotnolegs has joined #ruby-lang
seanstickle has joined #ruby-lang
arooni-mobile has joined #ruby-lang
qpingu has quit [Quit: Leaving.]
krz has quit [Quit: krz]
gsav has joined #ruby-lang
gsav has quit [Client Quit]
gsav has joined #ruby-lang
gsav has quit [Client Quit]
gsav has joined #ruby-lang
cirenyc has quit [Quit: Leaving...]
areil has joined #ruby-lang
gsav has quit [Client Quit]
gsav has joined #ruby-lang
gsav has quit [Client Quit]
gsav has joined #ruby-lang
wpaulson has joined #ruby-lang
replore_ has joined #ruby-lang
gsav has quit [Quit: Lost terminal]
gsav has joined #ruby-lang
cirenyc has joined #ruby-lang
charliesome has joined #ruby-lang
banisterfiend has joined #ruby-lang
faces has joined #ruby-lang
arooni-mobile has quit [Ping timeout: 246 seconds]
justinmcp has quit [Remote host closed the connection]
seanstickle has joined #ruby-lang
lun_ has quit [Remote host closed the connection]
qwerxy has quit [Quit: offski]
Hakon has quit [Quit: Leaving...]
ruurd has quit [Quit: Leaving...]
workmad3 has quit [Ping timeout: 246 seconds]
justinmcp has joined #ruby-lang
replore_ has joined #ruby-lang
icooba has joined #ruby-lang
diegoviola has quit [Ping timeout: 260 seconds]
jaska has joined #ruby-lang
gsav has joined #ruby-lang
znake|away is now known as znake
znake has quit [Quit: znake]
icooba has quit [Ping timeout: 268 seconds]
cantonic has joined #ruby-lang
sirfilip has joined #ruby-lang
<sirfilip>
morning
runeb has joined #ruby-lang
<seanstickle>
Good morrow to you, Sir Filip.
<seanstickle>
We are pleased to welcome your lordly self.
<matti>
LOL
<matti>
seanstickle: Now, you should add "Sir Filip, would you care for some tea and biscuits?" :)
<seanstickle>
matti: I am not a servant dogsbody
<seanstickle>
matti: I am a citizen of the Free States
<sirfilip>
:D
<seanstickle>
matti: and thus, in every way, this lord's equal
<matti>
I was just joking ;p
cantonic has quit [Quit: cantonic]
banisterfiend has quit [Remote host closed the connection]
banisterfiend has joined #ruby-lang
gsav has quit [Read error: Connection reset by peer]
gsav has joined #ruby-lang
gsav has quit [Read error: Connection reset by peer]
gsav has joined #ruby-lang
replore_ has quit [Remote host closed the connection]
justinmcp has quit [Remote host closed the connection]
gsav has quit [Ping timeout: 268 seconds]
qwerxy has joined #ruby-lang
codewrangler has joined #ruby-lang
sirfilip has left #ruby-lang [#ruby-lang]
seanstickle has quit [Quit: seanstickle]
headius has joined #ruby-lang
workmad3 has joined #ruby-lang
mistym has joined #ruby-lang
mistym has quit [Changing host]
mistym has joined #ruby-lang
_malte has joined #ruby-lang
Hakon has joined #ruby-lang
icooba has joined #ruby-lang
workmad3 has quit [Ping timeout: 252 seconds]
_malte has quit [Ping timeout: 246 seconds]
_malte has joined #ruby-lang
Hakon has quit [Client Quit]
rippa has joined #ruby-lang
snorkdude has joined #ruby-lang
Hakon has joined #ruby-lang
Hakon has quit [Client Quit]
qwerxy has quit [Quit: offski]
ttilley has quit [Ping timeout: 265 seconds]
rue has joined #ruby-lang
rue_XIV has quit [Ping timeout: 268 seconds]
Madis has quit [Ping timeout: 246 seconds]
Madis_ has joined #ruby-lang
rue_XIV has joined #ruby-lang
rue_XIV has quit [Remote host closed the connection]
gix has quit [Ping timeout: 240 seconds]
rue_XIV has joined #ruby-lang
qwerxy has joined #ruby-lang
qwerxy has quit [Client Quit]
gmci has joined #ruby-lang
rue has quit [Ping timeout: 260 seconds]
gix has joined #ruby-lang
Jake232 has joined #ruby-lang
s1n4 has quit [Quit: leaving]
rking has joined #ruby-lang
tonni has joined #ruby-lang
CoverSlide has joined #ruby-lang
rue_XIV has quit [Read error: Connection reset by peer]
rue has joined #ruby-lang
CarlB_the_great has joined #ruby-lang
rue_XIV has joined #ruby-lang
rue_XIV has quit [Remote host closed the connection]
rue_XIV has joined #ruby-lang
rue_XIV has quit [Remote host closed the connection]
rue_XIV has joined #ruby-lang
jastix has joined #ruby-lang
snorkdude has quit [Remote host closed the connection]
denysonique has quit []
rue has quit [Ping timeout: 276 seconds]
Nisstyre-laptop has joined #ruby-lang
lsegal has joined #ruby-lang
Erlkoenig has joined #ruby-lang
ttilley has joined #ruby-lang
rue_XIV has quit [Remote host closed the connection]
rue has joined #ruby-lang
rue_XIV has joined #ruby-lang
<Erlkoenig>
is it possible to create a "Method" or "Proc" object, while specifying the parameters via an array or something, and *not* by passing a block where the parameters have explicitly been defined? E.g. something like: params = [:a, :b, :c]; Proc.newWithParams(params) { |*x| ... } ... so that, when passed to define_method, the reflection methods would indicate "this method has 3 parameters :a, :b, :c" an not "this method has a res
<Erlkoenig>
rest/vararg parameter.
rue has quit [Ping timeout: 268 seconds]
nXqd has quit [Read error: Connection reset by peer]
rue_XIV has left #ruby-lang [#ruby-lang]
rue has joined #ruby-lang
<rue>
Erlkoenig: No, and it’s pointless. Who’s going to use those parameter names anyway?
<Erlkoenig>
well uhm the names aren't so much important, more the *number*
dbuckalew has joined #ruby-lang
<Erlkoenig>
so reflection will correctly report the number of arguments the method wants, and not just "it has a :rest parameter"
CarlB_the_great has quit [Remote host closed the connection]
havenn has joined #ruby-lang
sandbags has joined #ruby-lang
sandbags has quit [Changing host]
sandbags has joined #ruby-lang
<Erlkoenig>
also: is there a way, in a derived class' initialize method, to call the parent's initialize (like with "super"), without having to explicitly specify all the parameters - so the parameters for the parent's initialize() method can be modified, without having to modify all derived classes? and this without using a "rest/vararg" parameter, because then the reflection can't find out how many parameters the initialize method takes
mistym has quit [Remote host closed the connection]
<steveklabnik>
Erlkoenig: if you call super with no params it should use all the params
<steveklabnik>
i dont konw what happens if you changes it
<Erlkoenig>
yes, but it should only pass the parameters the parent class needs
outoftime has joined #ruby-lang
banisterfiend has quit [Read error: Connection reset by peer]
<steveklabnik>
it sounds like you're making your life really complicated
banisterfiend has joined #ruby-lang
<whitequark>
Erlkoenig: well, I think you have two options
<whitequark>
1. just eval that proc
<whitequark>
nevermind, the other one won't work on MRI.
seanstickle has joined #ruby-lang
<Erlkoenig>
ohmygod eval
<Erlkoenig>
i always forget about that beast
<whitequark>
eval isn't as bad as it seems to be. In the "initialization" stage (when the module-global code like "class Stuff; <here>; end" executes) it's pretty fine to use eval
<Erlkoenig>
thats an idea... thanks ;)
<whitequark>
it is indeed very evil at "runtime" stage
robin850 has joined #ruby-lang
<whitequark>
you can look at how useful and unobtrustive it is in ActiveSupport
nXqd has joined #ruby-lang
mistym has joined #ruby-lang
mistym has quit [Changing host]
mistym has joined #ruby-lang
<robin850>
hello
<robin850>
I just have a little question concerning methods
<robin850>
Is there a way to get the content of a method with Ruby ?
jastix has quit [Ping timeout: 246 seconds]
<robin850>
for example, If i have def foo(bar) return baz end, I would like to have a method which allows me to get "return baz"
nucc has joined #ruby-lang
banisterfiend` has joined #ruby-lang
<steveklabnik>
as a string?
banisterfiend has quit [Ping timeout: 252 seconds]
_malte has quit [Remote host closed the connection]
<banisterfiend>
robin850: just that there is a slightly different approach in each case :)
<robin850>
banisterfiend: In fact, in the library, when we create a new method (with def for example), I would like to create a new Method object with custom methods but I need the method content (the first one). For example create a method which return a canonical version of the method (it's quite hard to explain sorry, ^^)
<steveklabnik>
banisterfiend is the premier person to help you with this, robin850 :)
<steveklabnik>
sounds like EVERYBODY in #ruby-lang is trying to make their own lives hell for no reason today
<steveklabnik>
;)
<robin850>
steveklabnik: why hell ? ^^
<banisterfiend>
robin850: ok, outside of a REPL you can just use method_source to recover the source of the method (assuming the method is defined in a file and has a valid source_location)
<banisterfiend>
robin850: but inside a REPL the situation is more difficult, especially in IRB that does't have any support for recovering source for methods defined in irb
<banisterfiend>
robin850: i'll advertise Pry here :P because it was designed for this kind of thing from the beginning, and you can actually use the Pry::Method API to recover source in both cases, for REPL methods and for file-based methods
<Mon_Ouie>
He's already a Pry user
* Mon_Ouie
remembers seeing him post issues on the tracker
<banisterfiend>
robin850: for example: Pry::Method.from_str("YourClass#your_method").source
<banisterfiend>
and that works perfectly well for methods defined inside the Pry REPL too
<robin850>
banisterfiend, Mon_Ouie: Pry >> IRB
<banisterfiend>
robin850: we even allow recovery of class/module source
<banisterfiend>
robin850: and for a specific monkey patch of a class ;) Pry::WrappedModule.from_str("YourClass").candidate(2).source
<robin850>
banisterfiend: just works fine! :)
<Mon_Ouie>
banisterfiend: Btw, it's annoying that #doc doesn't return the documentation that e.g. ri would output for those modules
<Mon_Ouie>
(Well, mostly those written in C)
<banisterfiend>
Mon_Ouie: use yard_doc instead
<robin850>
banisterfiend: very nice you homemade scm for monkey patch ^^
<banisterfiend>
hmm
<banisterfiend>
Mon_Ouie: hmm, i dont remember the API there
<Mon_Ouie>
Does it work for modules that were defined at runtime and don't have their documentation generated? I kind of want the best of both worlds :p
<matti>
banisterfiend: :-]
Nisstyre-laptop has quit [Remote host closed the connection]
<banisterfiend>
Mon_Ouie: i dont really do anything fancy with the documentation, it's just the comments above the class def with the leading # stripped out and some of the yard tags colored prettily
<banisterfiend>
that should work at runtime on classes that dont have docs generated
<banisterfiend>
we should beautify it sometime
<Mon_Ouie>
I know, that already works in my ruby-dev.el :p (although it does more than that: it uses YARD::DocstringParser to handle YARD's tags)
<banisterfiend>
cool
banisterfiend has quit [Read error: Connection reset by peer]
havenn_ has joined #ruby-lang
banisterfiend has joined #ruby-lang
<banisterfiend>
we should probably just bite the bullet and put a hard dep on yard so we can use things like YARD::DocstringParser but people like to complain about dependencies
lsegal has quit [Quit: Quit: Quit: Quit: Stack Overflow.]
havenn has quit [Remote host closed the connection]
havenn has joined #ruby-lang
nucc has left #ruby-lang [#ruby-lang]
sepp2k1 has joined #ruby-lang
crackity_jones has joined #ruby-lang
sepp2k has quit [Ping timeout: 276 seconds]
cldwalker has joined #ruby-lang
GeekOnCoffee has quit [Read error: Connection reset by peer]
GeekOnCo- has joined #ruby-lang
macmartine has joined #ruby-lang
havenn has quit [Ping timeout: 244 seconds]
_malte has joined #ruby-lang
GeekOnCo- has left #ruby-lang [#ruby-lang]
<robin850>
Thanks for evryone for your help ! :) I think I will advise users to use Pry if they want to use the library in a REPL.
<banisterfiend>
k00
cantonic has joined #ruby-lang
_malte has quit [Remote host closed the connection]
Mellett68 has joined #ruby-lang
RegEchse has joined #ruby-lang
sandbags has quit [Ping timeout: 246 seconds]
_malte has joined #ruby-lang
sush24 has quit [Quit: This computer has gone to sleep]
nicebub has joined #ruby-lang
havenn_ has quit [Remote host closed the connection]
nofxx has quit [Ping timeout: 252 seconds]
crackity_jones has quit [Quit: Computer has gone to sleep.]
_malte has quit [Remote host closed the connection]
runeb has quit [Remote host closed the connection]
havenn has quit [Remote host closed the connection]
goshakkk has quit [Quit: Computer has gone to sleep.]
workmad3 has joined #ruby-lang
banisterfiend has quit [Read error: Connection reset by peer]
workmad3 has quit [Ping timeout: 244 seconds]
crackity_jones has quit [Quit: Computer has gone to sleep.]
savage- has joined #ruby-lang
banisterfiend has joined #ruby-lang
havenn has joined #ruby-lang
icooba has quit [Quit: Computer has gone to sleep.]
^sandbags^ has joined #ruby-lang
^sandbags^ has quit [Changing host]
^sandbags^ has joined #ruby-lang
sandbags has quit [Ping timeout: 246 seconds]
ruurd has joined #ruby-lang
ryanf has joined #ruby-lang
m3nd3s has joined #ruby-lang
<whitequark>
banisterfiend: what's with dependencies? Pry is a debug tool, it can require whatever it wants
havenn_ has joined #ruby-lang
_malte has joined #ruby-lang
havenn_ has quit [Ping timeout: 244 seconds]
runeb has joined #ruby-lang
s1n4 has joined #ruby-lang
crackity_jones has joined #ruby-lang
_malte has quit [Ping timeout: 246 seconds]
goshakkk has joined #ruby-lang
Jake232 has quit [Quit: Computer has gone to sleep.]
runeb has quit [Ping timeout: 244 seconds]
ruurd has quit [Quit: Leaving...]
tbuehlmann has joined #ruby-lang
d3vic3 has joined #ruby-lang
havenn has quit [Remote host closed the connection]
rippa has quit [Ping timeout: 252 seconds]
rippa has joined #ruby-lang
havenn has joined #ruby-lang
ruurd has joined #ruby-lang
artOfWar has quit [Remote host closed the connection]
<Mon_Ouie>
What does it change that it is a debugging tool (or that it can be used for that purpose at least)?
burgestrand has quit [Ping timeout: 272 seconds]
icooba has joined #ruby-lang
Asher has quit [Ping timeout: 246 seconds]
runeb has joined #ruby-lang
headius has quit [Quit: headius]
savage- has quit [Remote host closed the connection]
<Erlkoenig>
is there no exact "using namespace" aquivalent in ruby? 'include' doesn't seem to be the right one, as demonstrated here: http://pastebin.com/8hNdURHN ... the "Foo" namespace doesn't get just referenced, but somehow "copied" into the main namespace, and thereby a copy of all the variables is made... so lines 13 and 14 produce different(!) output.
workmad3 has joined #ruby-lang
runeb has quit [Ping timeout: 246 seconds]
chimkan_ has joined #ruby-lang
krohrbaugh has joined #ruby-lang
banisterfiend has quit [Read error: Connection reset by peer]
ruurd has quit [Quit: Leaving...]
<canton7>
Erlkoenig, makes more sense if you use a class variable there
banisterfiend has joined #ruby-lang
<Erlkoenig>
canton7: like declaring a class around "bla" and using @@bla ?
crackity_jones has quit [Quit: Computer has gone to sleep.]
bryno has quit [Read error: Operation timed out]
<canton7>
I'm not even sure what instance variables *mean* in a module context. looking that one up...
<manveru>
class variables create problems :)
<canton7>
they do
<manveru>
instance var is good for this
wallerdev has quit [Quit: wallerdev]
<manveru>
module X; @y = 1; end
<Erlkoenig>
that's exactly what i'm doing
<Erlkoenig>
and it causes the said problem
<Erlkoenig>
i end up having TWO "@y" variables
<canton7>
it's because the isntance variable's scope is that of the object which the module is included into
<canton7>
and presumably some other scope if it's not included into anywhere
<manveru>
maybe better to ask what you're trying to do :)
<manveru>
because that approach looks very... unorthodox
<canton7>
you'll notice that "@bla.object_id" is the same as "bla.object_id"
Jake232 has joined #ruby-lang
<canton7>
ah no i'm wrong there
<canton7>
oh no, I was using the wrong sample code
bryno has joined #ruby-lang
<canton7>
yeah, if you @bar ||= String.new("foo") inside the module, and include the module, then bar.object_id == @bar.object_id
<Erlkoenig>
manveru: well i'm just writing a library which creates some namespaces, and wich generates a few global variables. i then want to use short names in my program and therefore "include" the namespace-Modules
seanstickle has quit [Quit: seanstickle]
<canton7>
does that make sense? So if you include Foo, the instance variables are declared in the current scope
<manveru>
can you show code for that?
<canton7>
and iirc, class variables only bring problems when doing inheritence?
<Erlkoenig>
i was using these global variables as "@foo" in module context, thereby not really global, but module-instance-variables. but these get duplicated upon "include"
<manveru>
canton7: how's include not doing inheritance?
<Erlkoenig>
"Foo" is my library, and "bla" is supposed to return some global variable
<Erlkoenig>
i'm "include"ing the Foo module to avoid writing "Foo::" all the time
<canton7>
manveru, I'll admit I'm slightly out of my depth here, but I was under the impression that mixins and inheritence were different and distinct?
<manveru>
iota ~ % ruby -e 'module A; @x = 1; end; class B; include A; p ancestors[1].instance_variable_get("@x"); end'
<manveru>
1
<manveru>
instance variables are on self
<manveru>
include doesn't change self, it only changes the ancestors
<manveru>
which affects lookup for methods and constants
<manveru>
instance variables are never searched for further in the ancestral chain
Tearan has quit [Client Quit]
<manveru>
Erlkoenig: Foo.instance_eval{ blah }
<Erlkoenig>
yes... why isn't there something like "using namespace" that just prepends Foo:: everywhere where neccessary, and doesn't do all the fancy inheriting?
<Erlkoenig>
manveru: that won't work with multiple namespaces to include, will it?
<manveru>
i see one Foo :)
<manveru>
show some real code maybe?
<manveru>
just the fact that you're using String.new suggests to me that you probably haven't thought of all the better options since you don't know them yet
<Erlkoenig>
well assuming there are multiple namespaces like Foo, and they contain many classes, which i don't always want to prepend with Foo:: in the user code
<Erlkoenig>
String.new is just a stupid exampe
<manveru>
so how about making an anoymous module, include your dependencies, and instance_eval in that
robin850 has quit [Quit: Konversation terminated!]
<Erlkoenig>
http://pastebin.com/BudyG5Ca this is part of my code (its 1500 lines in total)... the last function, MakeRb.platforms should return one global variable. The user code below includes the namespace, end thereby ends up creating a copy of the @platforms variable
<manveru>
you're in luck, it's a hash
<manveru>
just make it a constant on MakeRb
<Erlkoenig>
well it's a question of principle, it might be something more elaborate
<Erlkoenig>
like in C++ and Java this is all trivial and causes no problems
<manveru>
i'm sure you know this, but the point of using other languages is to use different ways of solving things
<Erlkoenig>
well it wouldn't hurt ruby to have a "using namespace"-similar directive...
wallerdev has joined #ruby-lang
<manveru>
ruby is closer to smalltalk or lisp than c++ and java
<manveru>
there is
<manveru>
it's called eval
<manveru>
it changes what self you're looking at
<Erlkoenig>
yeah, but that only works on *one* namespace
<manveru>
as many as you include into the object
<manveru>
you can't have more than one self at a time though
<manveru>
which is where instance variables live
<manveru>
so either you use instance_variable_get on the object you know it's in
<manveru>
or you change self to that object
<manveru>
constant lookup is different from instance-variable lookup, so even after include it will be found
<manveru>
and unlike c++ or java, constants aren't constant
<Erlkoenig>
sounds somewhat complicated to do for every one global variable
<manveru>
global variables are something different
ruurd has joined #ruby-lang
<Erlkoenig>
well not really "global", rather module-instance-variables
<manveru>
sorry, but the way you're trying to go about this just makes things more complicated and fragile
<Erlkoenig>
well this was my first thought about how to do it, i didn't think much about it and ran into the said problem when using include
<manveru>
yeah
goshakkk has quit [Quit: Computer has gone to sleep.]
<whitequark>
manveru: never ever recommend eval for changing self.
<whitequark>
there is a family of methods dedicated for changing ruby's implicit contexts
<whitequark>
namely instance_exec and class_exec
<manveru>
well, if you want to continue driving in that direction, MakeRb.instance_variable_get('@platforms') or MakeRb.instance_variable_set('@platforms', x)
<whitequark>
they do not accept strings and therefore do not require a parser to be available at runtime, nor do they cause performance drops.
goshakkk has joined #ruby-lang
havenn_ has joined #ruby-lang
<Erlkoenig>
manveru: what would be the "correct" direction?
<whitequark>
in fact, instance_eval with a block is exactly the same thing as instance_exec, but the latter is the proper way.
voker57 has joined #ruby-lang
voker57 has quit [Changing host]
voker57 has joined #ruby-lang
<drbrain>
whitequark: manveru has been around here for a long time, I'm sure he'll recommend an appropriate course of action
<manveru>
whitequark: i used eval as wildcard for all the eval family, which includes the exec variants, sorry
<manveru>
you're right of course :)
<manveru>
but in this case it wouldn't help anyway
<manveru>
Erlkoenig: all that roundabout including for a method per module, how about just making them all in one module to begin with?
<whitequark>
drbrain: sorry, but I don't think that referring to someone's authority is a good way to solve technical questions.
<Erlkoenig>
manveru: there is not just one method per module. as i said, the module's code has 1500 lines, with many classes and methods.
<Erlkoenig>
and some more to come
<whitequark>
manveru: indeed, but there is a widespread opinion that eval is "evil", and it is in fact based on facts. _eval with a block is not, because that's not _eval, so I try to recommend its usage whenever applicable. Won't help here indeed.
chimkan_ has quit [Quit: chimkan_]
enebo has joined #ruby-lang
havenn_ has quit [Ping timeout: 276 seconds]
havenn has quit [Remote host closed the connection]
<drbrain>
whitequark: and jumping straight into a lecture isn't the best way to win friends and influence people, most of who have been here for ages already lump *exec and *eval into the same family like manveru
<whitequark>
drbrain: point taken.
<manveru>
Erlkoenig: i wish i had the time to walk you through all of this, but i've shown you ways, you can ask more about those if you like, i'm sure people will answer
havenn has joined #ruby-lang
<manveru>
first i gotta get my son to bed
<Erlkoenig>
hmm
<Erlkoenig>
i think i will class-@@-variables for now
<Erlkoenig>
*use
guns has joined #ruby-lang
jastix has quit [Quit: Leaving]
havenn_ has joined #ruby-lang
Tearan has joined #ruby-lang
crankharder has quit [Remote host closed the connection]
chimkan_ has joined #ruby-lang
havenn_ has quit [Remote host closed the connection]
jtoy has joined #ruby-lang
artOfWar has joined #ruby-lang
DEac-_ has joined #ruby-lang
DEac- has quit [Read error: No route to host]
Hakon has joined #ruby-lang
s1n4 has quit [Quit: peace out]
jtoy has quit [Quit: jtoy]
pr0ton has quit [Ping timeout: 264 seconds]
dreinull has quit [Ping timeout: 246 seconds]
workmad3 has quit [Ping timeout: 248 seconds]
qwerxy has joined #ruby-lang
banisterfiend has quit [Read error: Connection reset by peer]
ruurd has quit [Quit: Leaving...]
artOfWar has quit [Remote host closed the connection]
jtoy has joined #ruby-lang
lsegal has joined #ruby-lang
qwerxy has quit [Quit: offski]
Tearan has quit [Quit: Sleepy Badger....]
anannie has joined #ruby-lang
banisterfiend has joined #ruby-lang
justinmcp has joined #ruby-lang
<anannie>
I have a question regarding the evaluation of logical expressions during assignment. I've noticed that if I do x = function1 or function2, where both functions return true or false, it fails to evaluate and puts the value of function1 into the variable. However, x = (function1 or function2) works. Why is this so? Is there something else that's going on that I'm not aware of?
<Erlkoenig>
maybe "x = function1 or function2" is interpreted as "(x = function1) or function2"
runeb has joined #ruby-lang
<anannie>
Actually Erlkoenig the variable returns nil
<Erlkoenig>
how can a variable return something?!
<anannie>
I tried to find out what was happening with a puts, but it didn't work. It didn't display a value
<anannie>
Erlkoenig: when I tried to print it didn't display a value....
<Erlkoenig>
if im correct with "x = function1 or function2" is interpreted as "(x = function1) or function2", then, if function1 evaluates to nil or false, x will be assigned nil/false, and function2 will be executed, but its return value will be ignored
runeb has quit [Ping timeout: 245 seconds]
<anannie>
Erlkoenig: I think you're right. I'll do an experiment to check. (I'll make sure that the function always returns false by default...)
<anannie>
Erlkoenig: Do you know why Ruby evaluates things like this?
<Erlkoenig>
what? the currect solution would to use parasentheses, as in x = (function1 or function2)
<Erlkoenig>
it's probably just operator precedence... maybe "||" has higher precedence than "=" so it will work without the ( )
qwerxy has joined #ruby-lang
<whitequark>
Elico1: both `or' and `||' do short-circuiting
<whitequark>
Erlkoenig: well, short-circuiting exists in every modern language, and `and'/`or' was taken from Perl, so these are not precisely Ruby's oddities
Elico1 has joined #ruby-lang
havenn_ has joined #ruby-lang
<Erlkoenig>
whitequark: yeah, but the differences of || and "or" are maybe a bit... surprising ;)
<anannie>
whitequark: I use traffic light in the broad sense of something that controls the flow of something through channels. Over here the execution can take two channels or roads. The traffic light tells it which one to take. Do this, if you have done that and it works then that's great, but if it doesn't then do this. It's meta controlling the flow... Does that make sense?
<whitequark>
Erlkoenig: that's why I always get angry when I encounter someone's code with `or's and `and's all over the conditions, done probably to "increase readability" (it does not)
<Erlkoenig>
just as Pascal's "then" is definitively more readable than C's "{". :D
jackhammer2022 has joined #ruby-lang
<whitequark>
anannie: the point here (which also caused the behavior to be named "short-circuiting"), is that first part of condition is always executed, but second isn't. I see your idea, but it'd not make it more clear for me if someone explained it to myself this way :)
<whitequark>
Erlkoenig: worst of all, those pieces of code are almost always incorrect
<Erlkoenig>
oh neat
Elico1 has quit [Ping timeout: 260 seconds]
<whitequark>
well, because people who do know Ruby don't replace && with `and'
<Erlkoenig>
but wait... wenn writing true || foobar() then foobar() is never executed, just as with `or'
havenn_ has quit [Ping timeout: 246 seconds]
<whitequark>
Erlkoenig: indeed, but the problem is with precedence
<Erlkoenig>
yes, i see it
<whitequark>
e.g. and/or have the same precedence, whereas && and || do not!
<whitequark>
&& is like multiplication, and || is like addition in boolean logic
<whitequark>
so, && wins over ||
<Erlkoenig>
wah... relying on && and || precedence is like very evil... i'd always put () to make it perfectly clear
<Erlkoenig>
btw... what do `these quotes' exactly mean? how's that called?
voker57 has quit [Read error: Connection reset by peer]
<whitequark>
well, it depends whether you know boolean logic good. It was one of the first things I have learned in programming, so I never mess that up
<Erlkoenig>
at least using ( ) is more reader-friendly ;-)
<whitequark>
(quotes) terminals don't have proper English quotes (‘these’), so some programs, esp. those from GNU suite, emulate them with `these'
<anannie>
whitequark: Yup, in my head the word short circuiting means something quite different... It means slashing something and skipping over a large amount of in betweens (there is such a thing as a long circuit) so my analogy makes more sense to me in my head. Yes, I do know that I have a weird head. I'll use short circuiting to refer to it from now on though. Thank you for explaining the difference
<whitequark>
Erlkoenig: again, depends on a reader. You won't explain how regexps work each time you write one, right? Operator precedence is a part of language
<Erlkoenig>
whitequark: ah... and strictly, `these´ aren't correct either?
kain has quit [Ping timeout: 244 seconds]
qwerxy has quit [Quit: offski]
<whitequark>
Erlkoenig: how did you write that second quote?!
<whitequark>
*ahem*
<Erlkoenig>
pressing the ´ key on my keyboard? :D
tbuehlmann has quit [Remote host closed the connection]
<whitequark>
it's a grave accent, right? I don't have one
justinmcp has quit [Remote host closed the connection]
<Erlkoenig>
whats funny... correct „german quotes“ are not found on the german keyboard layout, and only automatically placed by some text programs, so everyone always just uses "the normal ones"
<whitequark>
well, I have compose key, so I use “English double quotes” and «Russian ones» when it makes sense
<Erlkoenig>
USB keyboards should just tell the OS which keymap is printed on them, so the OS can automatically choose the correct one
deryl has joined #ruby-lang
<whitequark>
good luck standardizing that
<Erlkoenig>
my university has many US layouts, with only a few english speakers here... driving me crazy .D
<whitequark>
... and now imagine the pain of using DVORAK
<Erlkoenig>
wah
<drbrain>
whitequark: it's quite pleasurable
<whitequark>
drbrain: unless you need to use someone else's computer
<Erlkoenig>
my prof had Dvorak set on his PC, while US layout was printed on the keyboard o.O
<whitequark>
Erlkoenig: doesn't matter for touch typists. I don't look at keys while typing at all.
qwerxy has joined #ruby-lang
<drbrain>
Erlkoenig: it's annoying to switch all the keycaps on laptops, so I've been typing Dvorak on qwerty-labeled keyboards for years
<drbrain>
Erlkoenig: ^^
<Erlkoenig>
yeah with exercise it's okay... but if you are not familiar with some layout :D
<whitequark>
also, there is no such thing as Russian Dvorak, so you can either get one layout properly or another
<Erlkoenig>
heck, even my friend's laptop's keyboards annoy me as hell because they just have different sizes for the keys, and slightly different layout
<whitequark>
and there are tons of places in world where qwerty is also used. Smartphones, "smart terminals" or whatever these things are called in your country (ATMs and other ATM-like machines for different tasks)
<Erlkoenig>
hm, my smartphone has qwerty as well, but i haven't seen a non-qwertz-ATM or terminal here yet
banisterfiend has quit [Read error: Connection reset by peer]
gmci has joined #ruby-lang
<Erlkoenig>
but that was from ebay... probably smartphones bought in normal shops have qwertz too
<whitequark>
I've seen АБВГДЕ ("ABCDEF") terminals here. quite irritating I'd say
<whitequark>
well, on an Android smartphone you can have custom keyboards
banisterfiend has joined #ruby-lang
<whitequark>
WP8 does not allow such a thing, and iPhone probably has all frequently used layouts
<Erlkoenig>
lol, pidgin doesn't render your cyrillian letters, but firefox does
<whitequark>
cyrillic :)
<Erlkoenig>
oh sorry :D
<whitequark>
maybe you don't have proper fonts installed. In my experience pidgin renders pretty much everything, incl. RTL and Kanji
<Erlkoenig>
hmm, possible... but most of the time i don't get cyrillic letters :D
<Erlkoenig>
fonts on linux seems to be a somewhat delicate topic...
havenn_ has joined #ruby-lang
qwerxy has quit [Quit: offski]
ryanf has joined #ruby-lang
<whitequark>
Erlkoenig: never had a fonts problem on linux (Debian)
<whitequark>
in 5+ years or so
Elico1 has quit [Ping timeout: 248 seconds]
<Erlkoenig>
hum, i remember having some on gentoo... the problem is probably that there are a few different ways to install fonts...
enebo has quit [Quit: enebo]
enebo has joined #ruby-lang
d3vic3 has quit [Quit: leaving]
Elico1 has joined #ruby-lang
^sandbags^ has quit [Remote host closed the connection]
h3x3d has joined #ruby-lang
gregmoreno has joined #ruby-lang
havenn_ has quit [Remote host closed the connection]
<h3x3d>
Hi.. Anyone here?)
<h3x3d>
alive i meen)
Elico1 has quit [Ping timeout: 246 seconds]
<h3x3d>
mean*
gregmore_ has quit [Ping timeout: 248 seconds]
Tearan has joined #ruby-lang
Elico1 has joined #ruby-lang
chimkan_ has quit [Quit: chimkan_]
<Erlkoenig>
no, i'm undead
jtoy has quit [Quit: jtoy]
<h3x3d>
That's perfect.. i need some help with design of my bycicle.. Can i ask questions here?)
<whitequark>
never ask to ask; just ask.
<whitequark>
this is what IRC is for.
qwerxy has joined #ruby-lang
<Erlkoenig>
... bicycle? oO
Criztian has joined #ruby-lang
<h3x3d>
ok)
<whitequark>
Erlkoenig: a Russian metaphor for NIH syndrome
<h3x3d>
I'm trying to implement async module based web app platform in ruby. I thought to create registry for modules, so that any part of application can use them, also, i can easily return a proxy for a remote module if needed, and application will work with it without code changes. The question is - is it a good idea, or maybe this is not actual in context of ruby?
Elico1 has quit [Ping timeout: 264 seconds]
<whitequark>
you can use DRb, but be wary of high-latency network
<whitequark>
this won't work if you need to communicate with anything except localhost
diegoviola has joined #ruby-lang
<Erlkoenig>
(00:05:03) whitequark: Erlkoenig: a Russian metaphor for NIH syndrome <-- err... WHAT?!
Elico1 has joined #ruby-lang
<whitequark>
Erlkoenig: NIH means not-invented-here. Have you ever seen some piece of well-known software reimplemented purely for the reason of not requiring an external dependency or being afraid to use someone else's code?
<whitequark>
that's what NIH syndrome is about
<Erlkoenig>
yeah i read it on wikipedia... but what does it have to do with bicycles, and with his question? Oo
<whitequark>
"creating a bicycle" means solving a problem which already has a well-known solution
<whitequark>
erm
<whitequark>
"inventing a bicycle"
<whitequark>
I dunno how that relates to his question either
<Erlkoenig>
ah okay, funny... russians re-invent bicycles, and all other parts of the world re-invent just the wheel? :D
wpaulson has joined #ruby-lang
<whitequark>
damnit. I knew there was a better analogy for that.
havenn_ has joined #ruby-lang
<whitequark>
indeed, "reinventing the wheel" fits way better
<Erlkoenig>
hm, in germany you also say that, while the german word for "wheel" can also refer to "bicycle" ... :D
<Erlkoenig>
hihi... probably because "wheel" is "rad" in german, and "bicycle" is "fahrrad", so "rad" might just be an abbreviation...
Elico1 has joined #ruby-lang
<h3x3d>
the question is not how to move some piece of code to another machine. I can do it through for example http, AMPQ, sockets, or some other transport..
<h3x3d>
I asked about creating registry with modules
isale-eko has joined #ruby-lang
<h3x3d>
something like this:
<h3x3d>
ModuleManager['log'].debug('string')
nofxx has quit [Ping timeout: 246 seconds]
<h3x3d>
instead of direct call to Logger, so that i can configure all of subsystems in one place, IoC
rebelcan has joined #ruby-lang
<whitequark>
well, there are IoC/DI systems in Ruby
havenn has quit [Remote host closed the connection]
Quatrerwin has quit [Remote host closed the connection]
havenn_ has quit [Remote host closed the connection]
<h3x3d>
yes.. The question is - why nobody use them? I know that i can override any method for class/instance on the fly, but isn't it 'monkey patching'?
<drbrain>
IIRC, early versions of net/ssh or capistrano used a DI framework, and it was terrible
nofxx has quit [Ping timeout: 244 seconds]
postmodern has joined #ruby-lang
seanstickle has joined #ruby-lang
Elico1 has joined #ruby-lang
banisterfiend has quit [Read error: Connection reset by peer]
solars has quit [Ping timeout: 244 seconds]
banisterfiend has joined #ruby-lang
qwerxy has quit [Quit: offski]
Elico1 has quit [Ping timeout: 276 seconds]
Elico1 has joined #ruby-lang
cout has quit [Ping timeout: 260 seconds]
nofxx has joined #ruby-lang
nofxx has quit [Changing host]
nofxx has joined #ruby-lang
cout has joined #ruby-lang
igotnolegs has quit [Quit: Fire walk with me]
justinmcp has joined #ruby-lang
havenn has joined #ruby-lang
Elico1 has quit [Ping timeout: 246 seconds]
Elico1 has joined #ruby-lang
justinmcp has quit [Ping timeout: 255 seconds]
<zzak>
not tsort?
Elico1 has quit [Ping timeout: 246 seconds]
Elico1 has joined #ruby-lang
banisterfiend has quit [Read error: Connection reset by peer]
banisterfiend has joined #ruby-lang
nXqd has quit [Remote host closed the connection]
Asher has joined #ruby-lang
urbanmonk has joined #ruby-lang
Hakon has quit [Quit: Leaving...]
<drbrain>
DI is different than topological sorting
<drbrain>
from Wikipedia, "Dependency injection is a software design pattern that allows a choice of component to be made at run-time rather than compile time."
mistym has quit [Remote host closed the connection]
<drbrain>
in Ruby, making the choice at runtime is easy, so there's no problem
<drbrain>
well, not one a DI framework would solve