Topic for #ruby is now Ruby programming language || ruby-lang.org || RUBY SUMMER OF CODE! rubysoc.org/ || Paste >3 lines of text in http://pastie.org || Para a nossa audiencia em portugues http://ruby-br.org/
heftig_ joined #ruby
tomzx joined #ruby
<Lann>
burgestrand: what do you mean by encoding awareness?
<Lann>
like ruby 1.8.7 cannot handle double byte characters?
tayy joined #ruby
<subr00t>
gn8
otakutomo joined #ruby
heftig joined #ruby
RomD` joined #ruby
albemuth joined #ruby
austinbv_ joined #ruby
Guest78465 joined #ruby
Axs joined #ruby
Draco__ joined #ruby
MasterIdler joined #ruby
tomzx_ joined #ruby
ali_h_ joined #ruby
adeponte_ joined #ruby
pen_isident joined #ruby
rob125 joined #ruby
fcoury joined #ruby
RomD joined #ruby
randym joined #ruby
replore_ joined #ruby
otakutomo joined #ruby
sean_m joined #ruby
eywu joined #ruby
Indian joined #ruby
Indian joined #ruby
mgualt joined #ruby
ephemerian left #ruby
mxweas_ joined #ruby
otakutomo joined #ruby
h4mz1d joined #ruby
TheNumb_ joined #ruby
mindCrime_ joined #ruby
MasterIdler_ joined #ruby
milkpost_ joined #ruby
MasterIdler_ joined #ruby
nerded joined #ruby
notjohn joined #ruby
Backsorry joined #ruby
amacgregor joined #ruby
MasterIdler_ joined #ruby
travisjeffery joined #ruby
door1602 left #ruby
austinbv joined #ruby
flip_digits joined #ruby
bwlang joined #ruby
milkpost_ joined #ruby
rsampaio joined #ruby
mxweas_ joined #ruby
Draco_ joined #ruby
ablemike joined #ruby
Draco_ joined #ruby
yfeldblum joined #ruby
ablemike left #ruby
hasrb joined #ruby
minijupe joined #ruby
badabim joined #ruby
gentz joined #ruby
jwmann joined #ruby
adelcampo joined #ruby
otakutomo joined #ruby
badabim joined #ruby
<aces1up>
how do i create a regexp.new from string that included /m ???
pen joined #ruby
<aces1up>
Regexp::MULTILINE do i need to use that in the options?
<samuelkadolph>
aces1up: Yes
pencilcheck joined #ruby
baroquebobcat joined #ruby
wyhaines joined #ruby
dbgster joined #ruby
nari_ joined #ruby
tomzx joined #ruby
tdubellz left #ruby
tdubellz joined #ruby
dotnull joined #ruby
jfredett joined #ruby
<tdubellz>
|^j0ng^Il: can you cut it out?
pen joined #ruby
<tdubellz>
!ops if you're there |^j0ng^Il is spamming on join via /msg
<mitchty>
I threw in what I came up with, its... hacky
Hachima joined #ruby
mindCrime_ joined #ruby
Draco_ joined #ruby
richo joined #ruby
<richo>
Is there a cleaner way to do arrayInstance.map!{ |v| v.nil? ? [] : v } # I'm replacing nil's with []
gregorz joined #ruby
gregorz left #ruby
<mitchty>
richo: array.map/collect! {|x| Array(x)} would be my solution
<mitchty>
then again i don't know what v is so its an assumption
<richo>
mitchty: is there overhead with Creating a stack of new arrays though? Some of them are potentially really big
<richo>
Oh sorry, arrayInstances is an array of potentially huge arrays
<mitchty>
richo: never tried it on huge arrays, profile it
<richo>
Will do. Thanks :)
<mitchty>
richo: but, and I can't entirely recall for 100% certainty, but I thought Array() just leaves its input as an array, otherwise it creates a new array with that as first element
<mitchty>
i'd test it in either case, but the core Kernel methods use Array() lots
<richo>
I just profiled it for my usecase * 10
<richo>
no appreciable difference
x0F__ joined #ruby
<mitchty>
i'd stick with Array(), its cleaner, also avoids nil entirely
<richo>
yeah, I just updated my implementation
<mitchty>
even if it manages to get inside, its gets arrayed
monkey13_ joined #ruby
<richo>
more importantly, if some fool breaks the other endpoint and it starts returning Fixnums instead of arrays or whatever
<richo>
it'll do it's best to make sane data
<mitchty>
well its as sane as what you send to it
<richo>
it pulls from an API developed in house but not by my team
<mitchty>
so spooky action at a distance, got it
Y_Ichiro joined #ruby
airhorns joined #ruby
notjohn joined #ruby
Nisstyre joined #ruby
flip_digits joined #ruby
pen joined #ruby
Indian joined #ruby
acts_as_david joined #ruby
dot_null joined #ruby
mikeric joined #ruby
parus joined #ruby
adurity joined #ruby
sdavis1 joined #ruby
otakutomo joined #ruby
syamajala joined #ruby
ryanf joined #ruby
macmartine joined #ruby
maggie_n joined #ruby
savage- joined #ruby
Draco_ joined #ruby
Banistertab joined #ruby
manizzle joined #ruby
vitoravelino joined #ruby
Banistertab` joined #ruby
banisterfiend joined #ruby
<austinbv>
say you have a dir structure like this https://gist.github.com/1384931 what require do you put in your spec_helper to test first_class.rb
<austinbv>
and does first class need to be in a module?
<austinbv>
oh it has to be in a dir called lib
<austinbv>
why's that?
radic joined #ruby
zodiak joined #ruby
randym_ joined #ruby
mrevil joined #ruby
rsampaio joined #ruby
krz joined #ruby
<mrevil>
is it possible to do ML or python style unwrapping with block parameters? EX: [[1,2]].map { | [a, b] | a+b } in this example each element of the list is an array with two elements, I want to ?unwrap? the array passed to the block without having to explicitly: [[1,2]].map { | x | x.first + x.last }
<mrevil>
you see this in ML pattern matching, and you can do it in python parameters
brownies joined #ruby
<brownies>
hmmmm
<brownies>
how do you guys keep the asset pipeline straight between staging and production? (on rails)
<brownies>
i have a pretty reasonable git branching model otherwise, but that damn asset pipeline...
<mrevil>
i .gitignore public/assets then when I commit to my production branch I regenerate the assets with RAILS_ENV=production and force commit, but I have no idea whether or not it's correct. it's sorta a PITA
<banisterfiend>
mrevil: yeah
<banisterfiend>
mrevil: [[1,2]].map { |a, b| a + b }
<brownies>
yea it is a pita
<mrevil>
oh, lemme try that brb....
<brownies>
the thing is that the staging environment is set up the same as production (obviously), which means it looks for precompiled assets as well
<brownies>
so if i recompile... push to staging... then checkout master and try to merge... terrible things happen.
<brownies>
s/master/production/
<banisterfiend>
brownies: maybe you'd get more help on #rubyonrails
<brownies>
i
<brownies>
i'll give it a shot, but in my experience #ror is all assholes.
<banisterfiend>
brownies: i think there's a few chans, maybe #railsbridge too
<banisterfiend>
not sure
steph021 joined #ruby
wyhaines joined #ruby
GreaseMonkey joined #ruby
<banisterfiend>
mrevil: it's actually even more advanced that that, check this out: a, (b, c), d = [1, [2, 3], 4]
<banisterfiend>
a -> 1, b -> 2, c -> 3, d -> 4
austinbv joined #ruby
<banisterfiend>
mrevil: you can nest () to destructure deeply nested data structures
ryanf joined #ruby
<mrevil>
sweet. got it, just restricted it and all my tests pass
<mrevil>
i love functional programming�. not starting a flame war or anything i just do
<richo>
actually it's nothing like xml :/
<mrevil>
you just get used to it, and you learn to think in that style
<shevy>
(so(is(it(more(like(LSD?
<mitchty>
the thing i find most amusing is people complaining about the parens, because foo() is worse than (foo )
<shevy>
yeah, every programming language wants you to think within its pattern and style
<mitchty>
err other way around, screw it i'm going to bed
<richo>
shevy: it's trivial to do lisp using indenting instead of parens with a preprocessor
<shevy>
cool
<shevy>
(
<shevy>
(hello
<shevy>
(from
<shevy>
(lisp
<mrevil>
brownies: I always recompile assets in master first, then merge to staging. if staging is ok then I'll merge master or staging into production
mxweas_ joined #ruby
<brownies>
yea but that would mean merging the latest version of my code into production *before* staging... which seems a bit backwards.
<brownies>
i get that you're still deploying to staging first, but still.
<mrevil>
you can merge from staging to production and everything will work cleanly
<mrevil>
you just don't want to regenerate assets in multiple branches and try to merge, you just need to pick one way and stick to it
otakutomo joined #ruby
<mitchty>
so i'm a rails nub (read don't use it), but couldn't you make an assets branch that you update and then merge that to staging/prod/master as needed?
dhruvasagar joined #ruby
Banistertab joined #ruby
AllStruck joined #ruby
banister_ joined #ruby
alanp joined #ruby
Mchl joined #ruby
ryanf joined #ruby
dhruvasagar joined #ruby
apeiros_ joined #ruby
ryanf joined #ruby
ksinkar joined #ruby
Banistertab` joined #ruby
Indian joined #ruby
artOfWar joined #ruby
austinbv joined #ruby
jhunter joined #ruby
davidedwardclark joined #ruby
dhruvasagar joined #ruby
amvishnu joined #ruby
davidedwardclark left #ruby
tomzx joined #ruby
<amvishnu>
bundler problem
hasrb joined #ruby
jhunter joined #ruby
cosmikduster joined #ruby
<cosmikduster>
Rubyspec is failing spectacularly for me using ruby-1.8.7-p352: http://pastie.org/2901852 . Can anyone tell why?
<ryanf>
are you sure it's supposed to pass?
<ryanf>
it's normal behavior in 1.8 for UnboundMethod#name to return a string instead of a symbol
<cosmikduster>
I'm not sure. I doubt Rubyspec would fail with 37 failures, 194 errors on 1.8.7.
yxhuvud joined #ruby
<cosmikduster>
What am I doing wrong?
<ryanf>
maybe you are accidentally invoking the 1.9 version of the spec somehow
vitoravelino joined #ruby
vitoravelino joined #ruby
pen joined #ruby
gayasentinel joined #ruby
bluOxigen joined #ruby
sdwrage joined #ruby
pencilcheck joined #ruby
mrpanda joined #ruby
StitchedKite joined #ruby
banisterfiend joined #ruby
jwang joined #ruby
p1d joined #ruby
kawa_xxx joined #ruby
kawa_xxx joined #ruby
crescendo joined #ruby
EddieBluh joined #ruby
djdb joined #ruby
smgt joined #ruby
kawa_xxx joined #ruby
banisterfiend joined #ruby
ChampS_ joined #ruby
kawa_xxx joined #ruby
apeiros_ joined #ruby
workmad3 joined #ruby
stoffus joined #ruby
onisen_ joined #ruby
Backsorry joined #ruby
AllStruck joined #ruby
mafolz joined #ruby
nanoyak joined #ruby
Backsorry joined #ruby
beseku joined #ruby
Maya-PSK joined #ruby
Ilithya joined #ruby
ckrailo joined #ruby
pen joined #ruby
Morkel joined #ruby
batlock666 joined #ruby
zommi joined #ruby
krz joined #ruby
sayem joined #ruby
furrykef joined #ruby
workmad3_ joined #ruby
pi3r joined #ruby
<furrykef>
If I do "module Foo def bar ... end end" (as opposed to "def self.bar"), what happens to bar? It doesn't seem to be usable either inside or outside the module.
<ryanf>
furrykef: you need to include the module in something
vitoravelino joined #ruby
jwmann joined #ruby
<mrpanda>
furrykef: include your module in class, and object of that class will inherit method bar
<furrykef>
Ah. I'm just using a module as a namespace.
<furrykef>
Not very successfully, it seems. If I define a class, I can't seem to use the methods at the top level of the namespace without specifying the namespace's name.
<furrykef>
From within that class's methods, I mean.
thecreators joined #ruby
Spockz_ joined #ruby
Helius joined #ruby
Ch4rAzZz joined #ruby
frerich joined #ruby
frerich joined #ruby
Seisatsu joined #ruby
cosmikduster left #ruby
sooli joined #ruby
petschbot joined #ruby
statarb3 joined #ruby
statarb3 joined #ruby
flippingbits joined #ruby
vitoravelino joined #ruby
vitoravelino joined #ruby
trivol joined #ruby
gayasentinel joined #ruby
alup joined #ruby
sdwrage left #ruby
moshee joined #ruby
moshee joined #ruby
cyri_ joined #ruby
james_cotterill joined #ruby
steakknife joined #ruby
BiHi joined #ruby
<steakknife>
I'm evaluating Ruby code obsfucators. Are there any obvious limitations such as code regeneration from in-memory objects?
mxweas_ joined #ruby
LittleBill902 joined #ruby
<steakknife>
Interesting comments on ruby forum on this topic btw.
nicoulaj joined #ruby
minijupe joined #ruby
thecreators joined #ruby
fermo joined #ruby
xpot joined #ruby
kawa_xxx joined #ruby
r0bby joined #ruby
ephemerian joined #ruby
thecreators joined #ruby
steakknife left #ruby
ammar01 joined #ruby
NuclearLucifer joined #ruby
<NuclearLucifer>
'lo
timonv joined #ruby
hemanth joined #ruby
jbpros joined #ruby
Backsorry joined #ruby
robyurkowski joined #ruby
pabloh joined #ruby
roaminghorse joined #ruby
<kke>
hmm, highline prints #<HighLine::Question 0x43987342798234> before each question
kassien joined #ruby
Pip joined #ruby
Pip joined #ruby
omry joined #ruby
kassien joined #ruby
drPoggs joined #ruby
danielpunt joined #ruby
petschbot_ joined #ruby
kassien joined #ruby
kassien joined #ruby
banisterfiend joined #ruby
kawa_xxx_ joined #ruby
mindCrime_ joined #ruby
randym joined #ruby
robyurkowski joined #ruby
EddieS joined #ruby
tatsuya_o joined #ruby
ultraviolet joined #ruby
hurikhan|Work joined #ruby
davids joined #ruby
mengu joined #ruby
<furrykef>
http://pastebin.ca/2094231 -- so I wrote this module to parse a mini-language to transform strings. It works on strings like "I want to [foo] a [bar] with a {baz|quux}", where [foo] means "replace this with a randomly chosen string found under the rule named 'foo'", and {baz|quux} means "randomly return one of baz or quux". Basically it's a text generation system.
<furrykef>
Though the code seems to work well, I don't like it very much. The code for the Processor class seems awkward.
a_a_g joined #ruby
<furrykef>
The Processor class was originally a single function, but I wanted to keep state like string position so I don't have to bend over too much when I delegate things to other functions.
jensn joined #ruby
<furrykef>
But I kinda don't like keeping track of the string position this way. If I forget a @pos += 1 somewhere, for instance, my code will get stuck in an infinite loop.
<furrykef>
Is there a better way to write this kind of system?
RomD joined #ruby
heftig joined #ruby
szallol_ joined #ruby
szallol joined #ruby
szallol__ joined #ruby
robyurkowski joined #ruby
ChampS_ joined #ruby
sandstrom joined #ruby
banisterfiend joined #ruby
ramusara joined #ruby
pen joined #ruby
Seisatsu joined #ruby
jensn_ joined #ruby
justinmcp joined #ruby
Cluster444 joined #ruby
vitoravelino joined #ruby
randym joined #ruby
Guedes joined #ruby
kawa_xxx joined #ruby
LouisJB joined #ruby
clockwize joined #ruby
Cluster2 joined #ruby
ksinkar joined #ruby
Cluster left #ruby
wang joined #ruby
iocor joined #ruby
mxweas_ joined #ruby
mxweas_ joined #ruby
vitoravelino joined #ruby
vitoravelino joined #ruby
emocakes joined #ruby
Paladin joined #ruby
maasha joined #ruby
nanoyak joined #ruby
__Genji_Richmond joined #ruby
fermion joined #ruby
dfamorato_ joined #ruby
workmad3 joined #ruby
justinmcp joined #ruby
vitoravelino joined #ruby
vitoravelino joined #ruby
Spockz joined #ruby
alup joined #ruby
bier joined #ruby
p0y joined #ruby
xec joined #ruby
Pip joined #ruby
Morkel joined #ruby
M- joined #ruby
M- joined #ruby
burgestrand joined #ruby
beilabs joined #ruby
apeiros joined #ruby
nerded joined #ruby
_2easy joined #ruby
jay_zawrotny joined #ruby
envygeeks joined #ruby
<envygeeks>
is there a way to force printf to no class kind of like Python
Shrink joined #ruby
trivol joined #ruby
bwlang joined #ruby
<apeiros>
envygeeks: what?
<envygeeks>
right now I have to printf %d and %s as two different strings, I want to printf without it caring about the object type
<envygeeks>
Idon't know if that's possible though, Google is telling me no
<apeiros>
depends on what you want it to do
<apeiros>
%s will invoke to_s on any non-string object
<apeiros>
so if that behaviour is fine, just use %s.
sven_ joined #ruby
<envygeeks>
oh, I did not know that that is perfect, thanks
<apeiros>
the same applies for other formats too, %d iirc invokes to_i, %f to_f etc.
tk_ joined #ruby
<apeiros>
ah, %d uses Integer(), not to_i
<apeiros>
so %f probably uses Float(), not to_f
<apeiros>
yupp
beiter joined #ruby
pen joined #ruby
dzhulk joined #ruby
jensn joined #ruby
dzhulk1 joined #ruby
danielpunt joined #ruby
Cervajz_ joined #ruby
<StitchedKite>
envygeeks printf is short for printformatted so use puts or object.to_s if applicable ;p
replore joined #ruby
terraUNDverra joined #ruby
S1kx joined #ruby
S1kx joined #ruby
iocor joined #ruby
paraglade joined #ruby
rickmasta joined #ruby
kf8a joined #ruby
oponder joined #ruby
ChampS_ joined #ruby
furrykef left #ruby
Morkel joined #ruby
samxor_ joined #ruby
iocor joined #ruby
emptyflask joined #ruby
luckyrub_ joined #ruby
dhodgkin joined #ruby
dhodgkin joined #ruby
yfeldblum joined #ruby
Cervajz joined #ruby
Shrink joined #ruby
victork joined #ruby
ultraviolet joined #ruby
shevy joined #ruby
Manhose joined #ruby
crankycoder joined #ruby
sbanwart joined #ruby
pen joined #ruby
randym joined #ruby
justinmcp joined #ruby
petschbot joined #ruby
BiHi joined #ruby
wereHamster joined #ruby
Manhose_ joined #ruby
mensch joined #ruby
cdepue joined #ruby
suung joined #ruby
darksk1ez joined #ruby
fermo joined #ruby
igorbozato joined #ruby
yalue joined #ruby
Dangr_ joined #ruby
jrbing joined #ruby
dhodgkin joined #ruby
bwlang joined #ruby
Monit0r joined #ruby
pen joined #ruby
paraglade joined #ruby
jensn_ joined #ruby
bwlang joined #ruby
tommyvyo joined #ruby
adambeynon joined #ruby
wyhaines joined #ruby
sepp2k joined #ruby
Knodi joined #ruby
akem joined #ruby
macabre joined #ruby
igorbozato left #ruby
davids joined #ruby
maxok joined #ruby
pHcF joined #ruby
beakerman joined #ruby
ph^_ joined #ruby
yekta joined #ruby
yfeldblum joined #ruby
michael_imac joined #ruby
moshee joined #ruby
moshee joined #ruby
iocor joined #ruby
jtrudeau joined #ruby
nerded joined #ruby
ohergal joined #ruby
evantravers joined #ruby
mocker joined #ruby
jfredett joined #ruby
cdepue_ joined #ruby
apow joined #ruby
robyurkowski joined #ruby
bwlang joined #ruby
adamjleonard joined #ruby
malkomalko joined #ruby
jensn joined #ruby
flip_digits joined #ruby
nanderoo joined #ruby
xpot joined #ruby
Draco_ joined #ruby
raluxgaza joined #ruby
sean_m joined #ruby
xpot joined #ruby
dv310p3r joined #ruby
grekko joined #ruby
Indian joined #ruby
lord12341 joined #ruby
<lord12341>
is it bad form to use "load" instead of require?
<burgestrand>
There’s often no reason to.
JohnBat26 joined #ruby
<burgestrand>
load will load a file more than once if asked to, it does not append the correct file ending to files (which could be problematic with loading C extensions) and is uglier than require. :p
vtr joined #ruby
<lord12341>
also: lets say I am in a array.each that contains a array of filenames, which loads each file. Is there a way to exit the "load" without exiting the entire run? (so, I found an error in filename1, but want to continue to filename2,3,4,...etc)
tvw joined #ruby
bluOxigen joined #ruby
albemuth joined #ruby
<terraUNDverra>
lord12341: rescue and next
bwlang joined #ruby
bwlang left #ruby
<terraUNDverra>
lord12341: [f1,f2,f3,f4].each { |v| begin; load v ; rescue ; next; end }
<lord12341>
ok
savage- joined #ruby
kawa_xxx joined #ruby
<burgestrand>
rescue does not catch LoadError
Jackneill joined #ruby
Jackneill joined #ruby
<burgestrand>
You’d have to “rescue LoadError” specifically
austinbv joined #ruby
KermitTheFragger joined #ruby
<KermitTheFragger>
hi all
<KermitTheFragger>
quick question of a ruby noob
chiel left #ruby
<burgestrand>
slow question, rather!
<burgestrand>
:d
<KermitTheFragger>
is it possible to have bundler install all the gems (dependencies) in to the local directory instead of globally ?
<KermitTheFragger>
yeah, im kinda slow ;-)
<terraUNDverra>
burgestrand: he said found an error *in* one of the files he's loading
<KermitTheFragger>
creating a sort of statically linked solution...
<burgestrand>
Yes it is
<terraUNDverra>
burgestrand: a load error will happen if the file doesn't exist
<austinbv>
so I have decided that I need to learn ruby instead of just being a rails programmer and I am confused when using attr_accessor why can you not access those methods from inside the class definition
<terraUNDverra>
i assumed he meant there was bad code in one of the files ;)
<burgestrand>
KermitTheFragger: --path might help you
<KermitTheFragger>
burgestrand: i already found the path thing, but the app is not smart enough to find the gems :(
<burgestrand>
KermitTheFragger: you*d have to require 'bundler/setup' in your app before you require the gems
bier|tp joined #ruby
bier joined #ruby
kennethreitz joined #ruby
raluxgaza joined #ruby
<austinbv>
or can you not access methods created with attr_accessor
<KermitTheFragger>
burgestrand: ok, thx ill go dig some more, atleast now i know it should be possible and im not perusing something that impossible :)
iamjarvo joined #ruby
ultraviolet joined #ruby
<KermitTheFragger>
burgestrand: i got something; RUBYLIB environmental variable should be helpful
<burgestrand>
austinbv: what’s your question?
tatsuya_o joined #ruby
<austinbv>
burgestrand: when you use attr_accessor to create getters and setters why can you not use those getters and setters in other methods
<austinbv>
meaning if you used a method name inside the same class you didnt need self
theRoUS joined #ruby
<burgestrand>
It’s not about intelligence, it’s about ambiguity
<envygeeks>
xissburg^mba: just a random thought but did you look at the configure.log?
<xissburg^mba>
yea, there I found "configure:3314: error: C compiler cannot create executables"
<xissburg^mba>
also "configure:3243: checking whether the C compiler works . . no"
<envygeeks>
paste the entire log to gist.github.com
Know1edge joined #ruby
<xissburg^mba>
it is looking for gcc at /usr/bin/gcc-4.2 or something but it doesn't exist.
akem joined #ruby
akem joined #ruby
dotnull joined #ruby
<burgestrand>
austinbv: in essence, since you can declare a local variable pretty much anywhere with anything, there is no way for ruby to know if you meant a local variable or a method call to the setter
<austinbv>
thats odd because in rails you can refer to other methods without self decleration
<burgestrand>
Rails is written in Ruby, it’s in ruby you can do that
<burgestrand>
But specifically for setters, this does not hold true
mcginleyr1 joined #ruby
<envygeeks>
Setters are scoped to the context austinbv
tomzx joined #ruby
<austinbv>
How do they do that?
nerded joined #ruby
<burgestrand>
What do you mean?
<austinbv>
scope the getters and setters to the context of each instance method
<xissburg^mba>
?
Morkel joined #ruby
manizzle_ joined #ruby
<austinbv>
nevermind
<envygeeks>
xissburg^mba: try --with-gcc=clang on the end of your rvm install, apparently there was a change in Ruby 1.9.3 (I don't know if it will work but apparently a lot of the failed compiles tend to be fixed by tht)
<burgestrand>
You’ll have to provide an example, because… they don*t
<Tasser>
is there kind of a result benchmark framework?
<burgestrand>
(and I think it’s better to use attr_accessor and self than instance vars, because attr_accessor just creates methods, and methods you can change without necessarily changing how you call them)
<burgestrand>
Using @var is like taking candy, while using just “var” is like asking for candy
<deryl>
errr?
<deryl>
thats all a matter of scoping
<austinbv>
I see
<deryl>
you're confusing everything every book is teaching me
lord1234 left #ruby
bbttxu joined #ruby
<burgestrand>
I'll illustrate what I mean
<deryl>
@var makes it accessible anywhere in the instance. var does not
<austinbv>
@var refers to the instance variable
<deryl>
please do. maybe i internalized what is being taught, wrong
<apeiros>
deryl: var being a method, I think
<apeiros>
(attr_*)
<austinbv>
its like in java being putting the method at the top of the class
<austinbv>
right?
<deryl>
i don't know enough java to say, personally.
<burgestrand>
I mean it’s better to use line #10 over line #9 if possible
<deryl>
10 you would have to use :var i thought
<deryl>
you're declaring a symbol
<deryl>
well it defines a vaariable but usig a symbol to access it
<burgestrand>
deryl: you mean “our_var = :var” ?
<deryl>
yeah
<burgestrand>
deryl: because that’s different
<burgestrand>
deryl: it’s like saying “our_var = 5” or whatever, :var is just a value
<austinbv>
isn't that just assigning the symbol :var to our_var
<deryl>
how so? (not being argumentative, asking for edification :) )
<burgestrand>
austinbv: yeah it is
pootpoot joined #ruby
<deryl>
ahh so the symbol becomes a pass-through
<burgestrand>
deryl: symbols are just another kind of data in ruby, there’s not much special about them, they’re like strings
<austinbv>
indexed strings iirc
<burgestrand>
our_var = "var" and our_var = :var are very similar
<deryl>
right but they refer to a specific memory location that contains a value, one that never changes (the mem loc)
<burgestrand>
(except that the first assigns our_var to "var" and the second one assigns it to :var, but it's still just simple local variable assignment)
<deryl>
correct?
<burgestrand>
I guess you could say that, yeah. I think of them like numbers.
norex joined #ruby
<deryl>
burgestrand: right but you're 'passing through' the symbol to get to the value stored at that location, correct?
<burgestrand>
Say, you have the number 5, it’s always 5. It never changes, it never moves, you cannot update it and you cannot change 5 to be 4.
<austinbv>
deryl: attr_accessor just used the method defination to set the getters and setters
<austinbv>
same as a named scope in ruby using :joins => :table_name
<deryl>
austinbv: right that i knew. i'm referring specifically to the symbol
<burgestrand>
deryl: no, no passing nothing special with “our_var = :var”, it just assigns “our_var” to the value :var
<austinbv>
ah
<deryl>
i think this is an aerea i'm lacking udnerstanding
JonnieCache joined #ruby
<deryl>
sorry typed so fast i'm typoing like mand :)
<deryl>
mad
<burgestrand>
If you think symbols are just strings that start with a colon instead of using apostrophes, you’re more than half right :)
vitoravelino__ joined #ruby
<austinbv>
like a man*
<deryl>
lol, well i am that :)
<deryl>
burgestrand: ok. i'll have to read more on the guts of symbols then.
<austinbv>
symbols are slower to write faster to read hence the immutable interned
<xissburg^mba>
rvm install 1.9.3 fails, but rvm install 1.9.2 doesn't...
<samuelkadolph>
Uhh no
<burgestrand>
Symbols are speedy, but the memory they use is never released
<samuelkadolph>
symbols are just like strings is almost every aspect except they are immutable and equality comparison is O(1) instead of O(N)
<deryl>
i've been thinking of symbols as: the machine selects a memory location, assigns ':var' as a handle for referencing that specific location (for humans), and then when you reference it you're storing whatever value you give it in that specific location, or readds from taht specific location.
<samuelkadolph>
deryl: Yeah they don't work like that
<burgestrand>
Oh, no, the value of a symbol is itself
<samuelkadolph>
The only reason they are used over strings is you don't have to allocate a new object for each literal (which could happen very often) and comparison is super fast
<samuelkadolph>
So they make really good hash keys
paraglade left #ruby
<burgestrand>
In reality, you very seldom need to use symbols, if you always use strings you should get along fine
<deryl>
i think it is the fact the id never changes is what confuses me.
<samuelkadolph>
deryl: Because they are all the same object
<samuelkadolph>
Just like 5 is 5 is 5, :abc is :abc is :abc
<austinbv_>
so is a symbol a refrence
<deryl>
right. vs. var or @var which could have different ids
<austinbv_>
oh wait I just got it
<samuelkadolph>
deryl: Those are variables, not literals
<deryl>
which part is the literal with symbols?
<samuelkadolph>
:abc is a symbol literal
<samuelkadolph>
"abc" is a string literal
<deryl>
becaue the value stored in the jobect referenced by the :symbol can change
* xissburg^mba
sighs
<samuelkadolph>
deryl: No, symbols are immutable
<deryl>
i know, but i'm not trying to change the symbol
cpruitt joined #ruby
<deryl>
i'm trying to change the value it references
<samuelkadolph>
Symbols aren't references to anything
<deryl>
hehe i think the understanding i thought i had is rapidly slipping away
Draco_ joined #ruby
<burgestrand>
:p
<burgestrand>
5 does not reference anything
<burgestrand>
:symbol does not reference anything
<burgestrand>
Hm, actually, this needs a new approach
<deryl>
please?
<samuelkadolph>
They are just immutable interned strings. Nothing less, nothing more
<burgestrand>
This is not the first time this discussion comes up :d
<samuelkadolph>
They don't point to anything
<deryl>
hehe. sorry if i'm making you rehash previous territory
yaasii_ joined #ruby
Paladin joined #ruby
<burgestrand>
deryl: do you know C?
paraglade joined #ruby
<deryl>
i was thinking that symbols were created objects where the id never changed so you always referred to *that* object (and it couldn't change because the assignment was immutable)
<burgestrand>
deryl: symbols are kind of similar to that; #define is very useful when you want a magical number of some sort, but don’t wish to use that number in your code because it’d be very confusing
eugynon joined #ruby
<deryl>
ah hah! now that clicked!
<burgestrand>
deryl: you could think of a symbol as a magical number, or rather a magical constant, that never changes
<samuelkadolph>
I rather dislike that explanation but it makes most people understand
<burgestrand>
It’s a process ;)
<deryl>
thank you for taking the time to explain that. i think i have it now
kawa_xxx joined #ruby
<deryl>
brb phone
SegFaultAX joined #ruby
<austinbv>
so I think I am off
<austinbv>
err wrong
<austinbv>
so why not only use immutable strings
<samuelkadolph>
For what?
<envygeeks>
for everything!
<austinbv>
oh wikipedia answered it
<samuelkadolph>
I love not needing a StringBuilder class in ruby.
<samuelkadolph>
One thing I always disliked about C#.
<austinbv>
why does ruby not work like java and make all strings immutable?
dv310p3r joined #ruby
<samuelkadolph>
Because it's a choice
<samuelkadolph>
And having immutable strings doesn't get you much in the end while preventing you from having efficient string manipulation.
<austinbv>
I need to take compliers 304
<austinbv>
instead of the 200level
<austinbv>
I think we would get to this stuff
<samuelkadolph>
Compiler != language
<envygeeks>
I was thinking that too, making everything immutable in a single threaded environment would probably add extra overhead you just don't want
<austinbv>
connect to my phone instead of my schools network
<xissburg^mba>
heeh
<envygeeks>
There has to be a much better way to get the class name of a method since self.name can be modified
<samuelkadolph>
Class name of a method?
<austinbv>
samuelkadolph: from that SO post The only real disadvantage of immutable classes is that they require a separate object for each distinct value.
<austinbv>
so for speed and security we should use symbols as often as possible
<samuelkadolph>
austinbv: That makes no sense
<samuelkadolph>
No
<austinbv>
I know there isn't a "right answer"
<austinbv>
I am just trying to figure it out :P
<samuelkadolph>
Immutable interned strings (or other things) leads to less instances
<samuelkadolph>
Because you can pool them
<samuelkadolph>
But that wasn't in the SO, so I'm not sure why you said that
<austinbv>
which is why :x.object_id === :x.object_id
<samuelkadolph>
There were some good points in those answers which you seemed to have not read
josemota_ joined #ruby
ph^ joined #ruby
<austinbv>
they use the same instance
<austinbv>
I am still reading
dcarper joined #ruby
airhorns joined #ruby
gearaholic joined #ruby
revans joined #ruby
<austinbv>
I still don't see why to use mutable objects from those answers
<samuelkadolph>
Those are points for immutable
pen_isident joined #ruby
ultraviolet joined #ruby
<austinbv>
right so why not always do puts :"hello world"
dch4pm4n joined #ruby
<austinbv>
or x = :"some sort of symbol"
<samuelkadolph>
Because in ruby symbols are memory leaks. They never get garbage collected
<austinbv>
ah that's what I was looking for
<samuelkadolph>
And they aren't mutable, so you cannot mutate them
<samuelkadolph>
Which is very convenient for building strings
<austinbv>
my computer is dying
<austinbv>
:(
kevinbond joined #ruby
omry joined #ruby
VJTachyon joined #ruby
<VJTachyon>
Anybody looking for some work in NYC?
oponder joined #ruby
<raluxgaza>
Hey guys how can I return a date in format "1st Nov"?
steph021 joined #ruby
metrix joined #ruby
steph021 joined #ruby
<samuelkadolph>
raluxgaza: I think you'd have to handle the ordinal yourself
<metrix>
I want to import a ruby file but I want the files scope to be visible within the object instance so that I can import the same file name/methods with different code in other object instances... Is there a way to do this?
macmartine joined #ruby
raluxgaz_ joined #ruby
omry joined #ruby
LiquidInsect joined #ruby
ghanima joined #ruby
omry joined #ruby
cjs226 joined #ruby
VJTachyon joined #ruby
ephesius joined #ruby
omry joined #ruby
vitoravelino__ joined #ruby
cdepue joined #ruby
omry joined #ruby
philcrissman joined #ruby
<aces1up>
when doing included(base) how can i get the name of the class its included into? base.class just returns class
SolarisBoy1 joined #ruby
abstrakt joined #ruby
<abstrakt>
is .each_slice deprecated in 1.9.2?
<samuelkadolph>
aces1up: base.name?
<abstrakt>
I've got require 'enumerator' as the first line
<samuelkadolph>
abstrakt: Why would it be?
<abstrakt>
but I'm getting an error about undefined method
<abstrakt>
I know this script has worked in the past and no changes have happened
<samuelkadolph>
That seems unlikely
S1kx joined #ruby
<abstrakt>
samuelkadolph, because I'm getting an error
<lirakis>
undefined method `[]' for #<Cinch::Bot:0x00000001fce620> (NoMethodError)
<Mon_Ouie>
PrivateType is probably the name of a class you're not supposed to deal with
<deryl>
its a default type, but not sure of ytype WHAT
Telling joined #ruby
<deryl>
lirakis: ahh. my bad
<catphish>
i think it might be an incarnation of nil actually
smgt joined #ruby
<catphish>
after a yaml decode
<lirakis>
hmm ... so any one have any idea how i can get to the instance vars that are symbols within an object?
<Mon_Ouie>
lirakis: An object doesn't have to provide a reader for its instance variables
<dominikh>
lirakis: just because an object has an instance variable doesn't mean there's an attribute reader for it.
<deryl>
err? didn;'t know there was more than one nil representation. thought that was ONLy NilClass
<lirakis>
right
<dominikh>
lirakis: furthermore, why do you want access to those variables? they're not exported for a reason
<catphish>
deryl: technically yes
<catphish>
but other code could put something in its place
<catphish>
instead of extending it
<deryl>
overriding?
<lirakis>
dominikh: yeah .. im using cinch which is an IRC framework. and i have written a bunch of plugins ... but i want to create a "list" command that will list the registered plugins
<lirakis>
dominikh: you are the cinch maintainer right?
<dominikh>
correct.
<lirakis>
so .. yeah .. im trying to basically get a list of registered event handlers
<lirakis>
from within my main bot
<dominikh>
you're using version 1.1.3 I assume?
Vendethiel joined #ruby
ahknight joined #ruby
ephesius joined #ruby
burgestrand joined #ruby
<lirakis>
hmm ... im not 100% sure id have to check
<lirakis>
cinch-1.1.3
<lirakis>
yeah
<dominikh>
well, you certainly don't need access to @events
enviable joined #ruby
<lirakis>
sure .. i was just .. trying to hack my way though to figure out where i could get the registered pattern matches
<lirakis>
i did an inspect on the whole bot object and i saw @events and the patterns within
<dominikh>
lirakis: why access the patterns and not the plugin instances?
<dominikh>
which would be Bot#plugins
<lirakis>
dominikh: so i tried looking at plugins too
<ahknight>
Quick newbie question, if you'll humor me: I'm trying to fix some Chef code and can't figure out what's going on somewhere (I'm a Py guy being drafted for the day.) What's this syntax for object creation called so I can Google it? group "some_group" do \n gid 600 \n end
<lirakis>
dominikh: i dont really know how the framework works all that much ... beyond using it to write simple irc bot plugins
<lirakis>
dominikh: so i wasnt sure where to look
<lirakis>
so i could do bot.plugins[:matchers]
<Mon_Ouie>
ahknight: That's just the syntax to call a method with a block
<lirakis>
?
paraglade joined #ruby
<lirakis>
hrm ..
<ahknight>
@Mon_Ouie Who receives gid? The group() I'm making, as in group.gid?
windowsrefund joined #ruby
<dominikh>
lirakis: version 1.1.3 doesn't provide attribute readers for most of the plugin attributes, so something like this will be needed: https://gist.github.com/2b9430d865d65b178310
<windowsrefund>
hi dominikh
<dominikh>
windowsrefund: hi.
<windowsrefund>
:)
bartavelle joined #ruby
<bartavelle>
is there a way to list all variables in scope ?
<Mon_Ouie>
ahknight: Most likely, they are using instance_eval, so it can be whatever object the library wants
<windowsrefund>
I"m getting #Net::HTTPOK strings in my http output when I use Net::HTTP. Can someone point me in the right direction for ensuring those are ommitted?
<lirakis>
dominikh: ok .. so i could use that block to collect the plugin help commands
rsampaio joined #ruby
<dominikh>
lirakis: yes
<ahknight>
@Mon_Ouie So, like keyword arguments? I don't see this syntax in any of the tutorials. :\
<lirakis>
dominikh: ok - that should work well enought
<poppiez>
I have ruby running optipng on a bunch of images but it's only using around 13 % CPU even though it takes forever. why isn't it more aggressive in CPU usage?
<DeeJayTwo>
Could someone tell me what's wrong my the way I call store on a hash?
<burgestrand>
initialize @aCtrl in the initialize method
<burgestrand>
That instance variable will be an instance variable on the class, and not on the instance you create by doing RAIDController.new
d3vic3 joined #ruby
<DeeJayTwo>
what's the purpose to have an instance variable on a class?
daniel_hinojosa1 joined #ruby
<DeeJayTwo>
by the way, thank you ;)
<burgestrand>
:)
<burgestrand>
It’s useful at times; you can create accessors/modifiers for it as well. You could use it as a counter, implement the Singleton pattern, and a bunch of other things I cannot think of right now.
fantazo joined #ruby
<DeeJayTwo>
ok, thank you!
<DeeJayTwo>
how do I refer to an instance class?
<burgestrand>
Other languages tend to have a similar thing named “static variables”; not exactly the same thing, but similar indeed
<DeeJayTwo>
from a method..
<burgestrand>
To an instance class?
Jake232 joined #ruby
steph021 joined #ruby
steph021 joined #ruby
<DeeJayTwo>
yeah... because obviously, I couldn't access it the way I did...
<burgestrand>
I mean I don’t understand you, please show what you want to do :)
<DeeJayTwo>
In my pastebin...
<DeeJayTwo>
suppose I kept in in the class
<DeeJayTwo>
but not in initialize...
<burgestrand>
Ah
<burgestrand>
You could do “def self.aCtrl; @aCtrl; end”
<burgestrand>
That would define aCtrl method on the RAIDController class
<burgestrand>
You could then access it with “self.class.aCtrl” or “RAIDController.aCtrl”
mengu joined #ruby
<burgestrand>
You could also define it as “def << self; attr_reader :aCtrl; end” (pretty much the same thing)
<burgestrand>
(semicolons in my code can be replaced with newlines, I just do it on one line because this… is… IRC!)
<DeeJayTwo>
good
<DeeJayTwo>
so I cannot set it after it is defined...
<DeeJayTwo>
right?
Guedes joined #ruby
Guedes joined #ruby
<burgestrand>
Sure you can, you just need to decide how!
tshauck joined #ruby
<burgestrand>
You could change the “attr_reader :aCtrl” to “attr_accessor :aCtrl” in my previous code sample; which I just noticed I had a syntax error in. It should read like this now, anyway: “class << self; attr_accessor :aCtrl; end”
LouisJB joined #ruby
<burgestrand>
Now you can set it with RAIDController.aCtrl = anything
<burgestrand>
ceej: "some string".encode(:xml => :text) might be enough
Manhose joined #ruby
<ceej>
burgestrand: both work :) including encoded_xml = xml.encode 'UTF-8', :xml => :text
<burgestrand>
:)
<burgestrand>
probably better with my latter suggestion, unless you really *want* to convert the data to UTF-8
iocor joined #ruby
mickn joined #ruby
dcarper joined #ruby
IrishGringo joined #ruby
robyurkowski joined #ruby
Rango joined #ruby
Mon_Ouie joined #ruby
<rtyler>
howdy chaps, I'm using capybara and was hoping somebody else had figured out how to add post-command hooks
<rtyler>
:)
paraglade left #ruby
Jake232 joined #ruby
Morkel joined #ruby
p1d joined #ruby
enroxorz joined #ruby
enroxorz joined #ruby
pHcF joined #ruby
apok joined #ruby
paraglade joined #ruby
workmad3 joined #ruby
ilyam joined #ruby
justinmcp joined #ruby
vitoravelino joined #ruby
felipe_Brz joined #ruby
felipe_Brz left #ruby
king313 joined #ruby
king313 joined #ruby
Manhose_ joined #ruby
kzar` joined #ruby
quest88_ joined #ruby
gbgallardo joined #ruby
<kzar`>
What's the ruby equivalent of (apply + [1 2 3])? (I would expect that to be 1 + 2 + 3 = 6.)
Azure joined #ruby
<gbgallardo>
Is this the appropriate place to ask rvm questions?
<LiquidInsect>
kzar`: [1,2,3].reduce(:+) is what I think you want
<kzar`>
LiquidInsect: Thanks
emocakes joined #ruby
dcarper joined #ruby
Guedes joined #ruby
evantravers joined #ruby
Guedes joined #ruby
h4mz1d joined #ruby
workmad3 joined #ruby
dzhulk joined #ruby
ixti joined #ruby
Targen joined #ruby
ixti joined #ruby
iocor joined #ruby
mib_mib joined #ruby
<ceej>
if I make a method that has a block and pass it a few things like yield(body, head, xml) how do I pass it by reference?
quest88 joined #ruby
<mib_mib>
hi - resque has been working fine for me, i use it with rails 3.0.4 - when i use QUEUE=blah rake environment resque:work RAILS_ENV=production - it works fine. recently I wanted to run multiple workers, so when i use COUNT=5 QUEUE=blah rake environment resque:workers RAILS_ENV=production it throws this required_dependency error - how do i fix it to run multiple workers? http://pastebin.com/vaLHH7jN
Russell^^ joined #ruby
senj joined #ruby
cooper joined #ruby
n8ji joined #ruby
dhodgkin joined #ruby
jbpros joined #ruby
sdavis joined #ruby
iocor joined #ruby
<ceej>
is there a way to get yield to send things by reference http://pastie.org/2905891 body still ends up blank…..
dhodgkin joined #ruby
<shadoi>
mib_mib: that's a rails internal require thing, is it loading rails before your worker code?
flock_ joined #ruby
<envygeeks>
is there a way to easily find out if a method is a singleton or an instance?
<shadoi>
ceej: your variables are local to the update method scope, you can use class methods or something…
<envygeeks>
Random question: Do you think I should still escape nested quotes or do you think most people will realise Ruby doesn't care about them?
sdwrage joined #ruby
<heftig>
envygeeks: example?
<envygeeks>
heftig: "My name is "EnvyGeeks""
<sullx>
\xBB is what i needed, thanks for the resources
Rango joined #ruby
<heftig>
envygeeks: that's a syntax error.
<Mon_Ouie>
envygeeks: That's a syntax error
<Mon_Ouie>
Heh
wereHamster joined #ruby
<envygeeks>
hmmm perhaps I had it wrong, I know there was a situation where I oculd nest quotes
<envygeeks>
let me find the example again >.>
<Mon_Ouie>
Yes, there's one
<Mon_Ouie>
%(foo (bar) baz)
<shevy>
don't think he meant that
<Mon_Ouie>
If you reach that case, I'd rather chose another delimiter than relying on that feature
<envygeeks>
Mon_Ouie, shevy, heftig: Here is the example binding.eval("#{Kernel.const_get("klass[:name]")}")
<shevy>
ewwww
<Mon_Ouie>
Ah, with string interpolation
M- joined #ruby
<Mon_Ouie>
I somehow avoid to have to interpolate complex expressions
<shevy>
thank god that I will never use something like that in my code
<Mon_Ouie>
Plus in that exact case you can just use to_s
<envygeeks>
I wanted to get the actual constant :P
fantazo joined #ruby
Code-Zombie joined #ruby
<Code-Zombie>
meow
<Code-Zombie>
setting up SFML with ruby under windows is a reaaaaaaal pain
Skaag joined #ruby
ikaros joined #ruby
skrewler joined #ruby
Axsuul joined #ruby
cjs226 joined #ruby
albemuth joined #ruby
cdepue joined #ruby
apok_ joined #ruby
wuntee joined #ruby
iocor joined #ruby
<wuntee>
how do i print the binary (NOT as in 1 and 0) representation of an unprintable character, for example puts("\231") will simply print "?" …. i want it to print whatever that would be if it existed in a file and i cat'ed the file
jbpros_ joined #ruby
<Mon_Ouie>
puts "\231" writes 0231 (i.e. byte 153) to stdout, followed by a new-line
techhelp joined #ruby
artOfWar_ joined #ruby
<wuntee>
Mon_Ouie: hmm - maybe its just rib thats sanitizing… thanks
<wuntee>
wuntee:~$ cat x
<wuntee>
puts("\213")
<wuntee>
wuntee:~$ ruby x
<wuntee>
?
macabre joined #ruby
<Mon_Ouie>
ruby -e 'puts "\213"' # I don't see anything in the output, wc tells me there's one byte
Clooth joined #ruby
Manhose__ joined #ruby
Banistergalaxy joined #ruby
<wuntee>
Mon_Ouie: what ruby version are you running?
cdepue joined #ruby
<Mon_Ouie>
1.9.3
pootpoot left #ruby
<wuntee>
hmm, 1.9.2 and 1.8.7 both show '?' when i run that command
<Mon_Ouie>
But I am pretty sure no Ruby version would replace non-printable chaaracters with question-marks
<Mon_Ouie>
Of course your teminal can do that
<Mon_Ouie>
terminal*
Cervajz joined #ruby
developish joined #ruby
<wuntee>
ahh - you are correct… it was the terminal...
<wuntee>
Mon_Ouie: thanks!
<sdwrage>
what is the difference between using @ and self?
<Mon_Ouie>
@ is the sigil for instance variable
<Mon_Ouie>
self is the current object (i.e. the object the current method was called on)
dankest joined #ruby
<sdwrage>
confused as I thought @age called that objects age var
<Mon_Ouie>
@age access the age instance variable of self
<Mon_Ouie>
accesses*
<sdwrage>
so self references the main object that my current object instances from?
<sdwrage>
basically the same thing as static calls in other langs
<Mon_Ouie>
No. self is like this in C++ or self in Obj-C
artOfWar joined #ruby
<sdwrage>
hold on… so I have User and then I have jason = User.new
<sdwrage>
which does self reference if I am using it in jason?
<sdwrage>
jason.methodwithselfcallinside
<jrist-out>
j...son
<jrist-out>
not jason
nari_ joined #ruby
<sdwrage>
jrist-out: I am not talking about json
<Mon_Ouie>
Jason. You called a method on jason, self is therefore jason in that method.
<jrist-out>
lol
<jrist-out>
k
savage- joined #ruby
<sdwrage>
Mon_Ouie: and if I did the same thing with @?
<sdwrage>
jason.methodwithatsymbolinside
<sdwrage>
what would that reference?
<ceej>
why does encoded_xml = xml.encode :xml => :attr wrap the string in quotes?
<Mon_Ouie>
Instances variables of self, i.e. jason