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/
<examancer>
that particular doc also shows you the methods from Enumerable, so it shows #delete_if as a method of Hash
snip_it has quit [#ruby]
<atheken>
seanstickle: FWIW, I think it's because I had a thin process running via pow! that has been up for awhile and I have been mucking about with rvm today, running 'rails s' works fine with the new syntax, sorry for bothering you.
ZenBalance has joined #ruby
<seanstickle>
Ha
<seanstickle>
Well, all's well that ends well
<superman_ffm>
you mean on the left side there are Enumerable
<examancer>
superman_ffm: yes
<atheken>
seanstickle: thanks for (trying) to help. cheers.
<banisterfiend>
seanstickle: hey sean
<seanstickle>
Hey banisterfiend !
<superman_ffm>
ant the Enumerable belongs to Hash
<banisterfiend>
sup
atheken has quit [#ruby]
thats_my_hat has joined #ruby
<examancer>
superman_ffm: Enumerable is a module. it is included into a number of other things and you can even use it directly.
asteros has joined #ruby
<seanstickle>
Actually, I don't think delete_if is an Enumerable method
_|christian|_ has joined #ruby
<ZenBalance>
Hi all, could anyone explain the following code: http://titanpad.com/HTk7v7ojAx I am trying to wrap my head around the concept of threading
<examancer>
superman_ffm: think of it like a parent class... its a little different than that, but that's the best description if you come from a language that uses classical inheritence
<examancer>
seanstickle: looks like you're right
<examancer>
i'm not sure why you didn't see that method then superman_ffm ... its just a normal hash method
<examancer>
:-P
<superman_ffm>
I see it now, and the k is for key and the v for value
nyrb has joined #ruby
joslin01 has joined #ruby
jobicoppola has joined #ruby
nerdy has joined #ruby
mmokrysz has joined #ruby
<joslin01>
kind gentlemen, I'm following the popular rails tutorial. guard is crying about libffi
<examancer>
lol. i for one thank mamina for the link
randym has joined #ruby
Natch| has joined #ruby
drPoggs has joined #ruby
ReinH has joined #ruby
S2kx has joined #ruby
<td123>
lame low-res spam
randym has joined #ruby
Apocalypse has joined #ruby
Karmaon has joined #ruby
dagnachewa has joined #ruby
genexp has joined #ruby
replore has joined #ruby
havenn has joined #ruby
colint_ has joined #ruby
tomzx has joined #ruby
havenn has joined #ruby
fayimora has joined #ruby
stephenjudkins has joined #ruby
<wroathe>
So I'm trying to write a method to recursively reverse the digits of an integer in ruby. So far here's what I've got http://pastie.org/3370740 How can this be improved?
<wroathe>
I'd like to avoid typecasting in that second return
<td123>
wroathe: if it's not immediately obvious, think about how our numbers work (how do you construct a value from the sequence of numbers we write down)
<seanstickle>
Ah perfect
BSaboia has joined #ruby
Shamgar has joined #ruby
genexp has joined #ruby
astrostl has joined #ruby
<wroathe>
It will only be base 10 integers and I have no idea :P
<wroathe>
How would you express that last return statement then?
<BSaboia>
hey guys... what is the "best way" of implementing tabs? segmented view is a good choice?
<BSaboia>
sorry, wrong # =\
ReTFEF has joined #ruby
genexp has joined #ruby
vaxinate has joined #ruby
<wroathe>
td123 what do you think is immediately obvious about it?
<wroathe>
I'm not following you
i8igmac has joined #ruby
genexp has joined #ruby
<td123>
wroathe: I'm assuming this is some kind of challenge so I'm trying not to give you too many hints :P
CannedCorn has joined #ruby
dyer has joined #ruby
mpabst has joined #ruby
kmurph79 has joined #ruby
<wroathe>
No. It's for project-euler... It's one part of an overall problem. If I wanted to do things the easy way with ruby I could cast the number to a string and do string.reverse and then cast it back to an integer.
<wroathe>
I'm just having a little fun.
<wroathe>
That code I just linked is my best attempt so far but I'm not really a math guy.
<swarley>
anyone have an answer as to how i make an irc client with GTK, i dont know how to get around the blocking
affix has joined #ruby
p0y has joined #ruby
crazed has joined #ruby
G has joined #ruby
DFectuoso has joined #ruby
zoo-zed has joined #ruby
<banisterfiend>
swarley: sshhh, i want to listen to the music
<swarley>
:[ but i have no idea how to do it QQ
MetaCosm has joined #ruby
huxley_sparks has joined #ruby
jwmann has joined #ruby
mikepack has joined #ruby
colint has joined #ruby
huxley_sparks has joined #ruby
<td123>
swarley: what blocking? are you using threads?
<swarley>
td123, no, but GLib should block indefinitely right?
nobitanobi has joined #ruby
kmurph79 has joined #ruby
<td123>
nvm, I was thinking about something else
jordanstephens has joined #ruby
DFectuoso has joined #ruby
lewix has joined #ruby
jacktrick has joined #ruby
sekati has quit [#ruby]
pen has joined #ruby
rsaaguy has joined #ruby
havenn has joined #ruby
savage- has joined #ruby
Rishi_ has joined #ruby
td123 has joined #ruby
gokul has joined #ruby
flip_digits has joined #ruby
DFectuoso has joined #ruby
vraa has joined #ruby
flip_digits has joined #ruby
G has joined #ruby
Ownatik has joined #ruby
flip_digits has joined #ruby
flip_digits has joined #ruby
Rishi_ has joined #ruby
fallen has joined #ruby
flip_digits has joined #ruby
G has joined #ruby
rippa has joined #ruby
18WABL9IC has joined #ruby
<Zolrath>
I'm trying to use something that has an Hpricot dependency, but Hpricot is crashing and reporting the wrong version of Ruby for some reasons?
<RubyPanther>
Zolrath: that's a weird one, something is getting the wrong version... like it is setting the current load path but then running the old ruby
<RubyPanther>
and Hpricot is just the first native extension that tries to load
<Zolrath>
Would that be something wrong with my gem command, building native extensions with system ruby then placing them in my rvm ruby directory or something?
<Zolrath>
I don't really see how this is happening
<RubyPanther>
Zolrath: I don't know how the vim stuff works, but it sounds like you have an app using an embedded Ruby 1.8.7 and then you're trying to load a gem that you installed into an rvm ruby
<Zolrath>
RubyPanther That makes way way more sense
<Zolrath>
RubyPanther: Vim was compiled with ruby support with an old version. Thank you very much!
Silker has joined #ruby
nari has joined #ruby
banisterfiend has joined #ruby
CannedCorn has joined #ruby
<RubyPanther>
Yay!
Sailias has joined #ruby
mdel has joined #ruby
kp666 has joined #ruby
td123 has joined #ruby
sythe has joined #ruby
sythe has joined #ruby
otakutomo has joined #ruby
akem has joined #ruby
vraa has joined #ruby
chiel has joined #ruby
<chiel>
Hi guys
<chiel>
is there something in ruby like the magic __set method in php?
kp666 has joined #ruby
<banisterfiend>
chiel: since we're generally not php programmers you're going to have to explain whta that method does :)
<chiel>
banisterfiend: right, sorry. :P basically, if you define a class, and create an instance of it, you can do something like this:
<chiel>
$var = new SomeClass(); $var->someValue = 'bla';
<chiel>
then, class SomeClass { function __set($key, $value) { /* do something */ } }
<chiel>
so you can basically assign any key/value pair.
<banisterfiend>
chiel: sorry i still dont know wtf your'e talking about
<chiel>
so instead of having to do `def key=(value) end` a bunch of times... i would only hve to define it once.
<chiel>
okay, one moment!
<banisterfiend>
chiel: but i think what u want is OpenStruct
opin_ has joined #ruby
<banisterfiend>
chiel: alternatively you could role your own solution using method_missing
<chiel>
so i just want to avoid having to define a setter for each key that i want to be ble to assign
<chiel>
but that openstruct thing looks like it kinda does what I want
<banisterfiend>
chiel: then inherit from OpenStruct
<banisterfiend>
chiel: class MyClass < OpenStruct
h4mz1d has joined #ruby
<chiel>
hmm yes, gonna give it a shot
rickmasta has joined #ruby
Axsuul has joined #ruby
trend has joined #ruby
nobitanobi has joined #ruby
<nobitanobi>
night guys
nobitanobi has quit [#ruby]
mxweas_ has joined #ruby
<banisterfiend>
burgestrand: Three Swedish switched witches watch three Swiss Swatch watches switches. Which Swedish switched witch watch which Swiss Swatch watch witch?
jaywastaken has joined #ruby
tonini has joined #ruby
chiel has quit [#ruby]
JohnBat26 has joined #ruby
c0rn has joined #ruby
capelio has joined #ruby
nemesit has joined #ruby
sjang1 has joined #ruby
bmagsipoc has joined #ruby
whereswaldo2 has joined #ruby
ABK has joined #ruby
savage- has joined #ruby
xiaotian has joined #ruby
intacta has joined #ruby
stephenjudkins has joined #ruby
djdb has joined #ruby
jhunter has joined #ruby
Karmaon has joined #ruby
GoBin has joined #ruby
yxhuvud has joined #ruby
daglees has joined #ruby
pen has joined #ruby
Sailias has joined #ruby
punkrawkR has joined #ruby
Illiux has joined #ruby
hmans has joined #ruby
senny has joined #ruby
samuel02 has joined #ruby
Sliker has joined #ruby
iocor has joined #ruby
gokul has joined #ruby
trivol has joined #ruby
Jarred has quit [#ruby]
Shrink has joined #ruby
odinswand has joined #ruby
mafolz has joined #ruby
flak has joined #ruby
bjensen has joined #ruby
opin_ has joined #ruby
snearch has joined #ruby
gokul has joined #ruby
paissad has quit ["Leaving"]
Morkel has joined #ruby
triptec has joined #ruby
intacta has joined #ruby
zommi has joined #ruby
bobby has joined #ruby
fenix457 has joined #ruby
ph^ has joined #ruby
sdwrage has joined #ruby
n8ji_ has joined #ruby
benregn has joined #ruby
snearch has joined #ruby
Doppp has joined #ruby
bier_ has joined #ruby
arturaz has joined #ruby
Sliker has joined #ruby
gmwils has joined #ruby
nemesit has joined #ruby
kreantos has joined #ruby
trivol has joined #ruby
js__ has joined #ruby
ZenBalance has joined #ruby
<ZenBalance>
Does anyone know what the inner text of a link is called attribute wise?
<banisterfiend>
ZenBalance: cindy
<ZenBalance>
I am trying to use it for a css selector scraping with nokogiri
<ZenBalance>
as in <a href="http://...">THIS</a>
<ZenBalance>
what would "THIS" be referred to as for a css selector?
<banisterfiend>
ZenBalance: ask in #rubyonrails
christianreber has joined #ruby
samuel02 has joined #ruby
Doppp has joined #ruby
ZenBalance has quit ["Leaving"]
timonv has joined #ruby
Jamoka has joined #ruby
cyri_ has joined #ruby
triptec has joined #ruby
Asher has joined #ruby
pi3r has joined #ruby
bluOxigen has joined #ruby
etehtsea has joined #ruby
triptec_ has joined #ruby
cakey has joined #ruby
csherin has joined #ruby
thats_my_hat has joined #ruby
sterNiX has joined #ruby
bjensen has joined #ruby
JohnBat26 has joined #ruby
davidpk has joined #ruby
nd____ has joined #ruby
gianlucadv has joined #ruby
adman65 has joined #ruby
king313 has joined #ruby
dennda_ has joined #ruby
Seisatsu has joined #ruby
iocor has joined #ruby
Spockz has joined #ruby
transtionstate has joined #ruby
canton7 has joined #ruby
<transtionstate>
ok... any of my mates here knows a thing or two abt rails.. coz then it will be great as the ppl in the rails room are more into gossiping and abuse than talking actual rails stuff... which is annoying
xastion has joined #ruby
<banisterfiend>
transtionstate: we hate rails in here
<banisterfiend>
:D
<banisterfiend>
transtionstate: try #railsbridge
banseljaj has joined #ruby
<transtionstate>
banisterfiend: ya mate but may b someone could help me out... its a small doubt that I have am new to rails myself so :)
<transtionstate>
i have my rails_root/config/models/en.yml file and this is how the file looks like and all i wanna know is how i could view a "Bet" using the i18 on my view page :)
<pvgrif>
i merge hash A with hash B and i like to hash B keys to stay at the back, is this possible?
<td123>
I was wondering where the new version was announced, and how distrowatch got it before the svn or git repositories got it
<banisterfiend>
phew
<banisterfiend>
i hope the new 1.9.3 patchlevel is less buggy
<banisterfiend>
1.9.3 was pretty buggy in places
<banisterfiend>
p0
<JonnieCache>
lol im pulling 32 kb/s from ftp.ruby-lang.org
<JonnieCache>
that cant be right
sobering has joined #ruby
adeponte has joined #ruby
MrGando has joined #ruby
theRoUS has joined #ruby
sonkei has joined #ruby
dv310p3r has joined #ruby
<shevy>
JonnieCache hah you third world country connection dude!
uris has joined #ruby
<JonnieCache>
nope its fast for everything else
dark3rdre4ms has joined #ruby
tomzx has joined #ruby
LMolr has joined #ruby
PragCypher has joined #ruby
PaciFisT has joined #ruby
fai|safe has joined #ruby
looopy has joined #ruby
PaciFisT has joined #ruby
robbinn has joined #ruby
bbttxu_ has joined #ruby
sobering has joined #ruby
sobering has quit [#ruby]
dandrinkard has joined #ruby
jxpx777 has joined #ruby
jxpx777_ has joined #ruby
IAD has joined #ruby
ryannielson has joined #ruby
iocor has joined #ruby
neurodrone has joined #ruby
neurodrone has joined #ruby
dark3rdre4ms has joined #ruby
dark3rdre4ms has joined #ruby
achievbot has joined #ruby
Sailias has joined #ruby
tatsuya__ has joined #ruby
Sailias_ has joined #ruby
jordanstephens has joined #ruby
Sailias_ has joined #ruby
Sailias has joined #ruby
geekbri has joined #ruby
Guest35831 has joined #ruby
tai has joined #ruby
<tai>
Is it canonical to omit or include parentheses in function calls? It seems to me that a function call can be written either of 2 ways [new to Ruby here, coming from a Python/Java background]
Targen has joined #ruby
bluenemo__ has joined #ruby
gvt has joined #ruby
tonini has joined #ruby
<rippa>
tai: parens are usually used for disambiguation/method chaining/readability
<shevy>
tai usually people omit it when there are no arguments
<shevy>
cat.meow
<shevy>
vs
<shevy>
cat.meow()
adambeynon has joined #ruby
<shevy>
but you can use them all the time if you want to
<JonnieCache>
yeah nobody ever does meow()
<shevy>
what I hate are method definitions that omit ()
<JonnieCache>
but using them with arguments is a matter of taste really
<shevy>
I mean, when there are arguments
<shevy>
def foobar one, two, three
csherin has joined #ruby
<JonnieCache>
shevy: thats rare too in my experience
* shevy
looks around
<shevy>
there are guilty people in here!
<tshirtman>
i thought it was the way to do it in ruby when i started reading about it
<tshirtman>
like removing everything superficial was the aim
<shevy>
hmm
<shevy>
I usually like being succint and short
<shevy>
and then omit things that are not needed
dnyy has joined #ruby
<tshirtman>
as long as it doesn't break readability, right?
<shevy>
well yeah kinda
<shevy>
or perhaps more importantly... when my brain has to think
seanstickle has joined #ruby
<tshirtman>
that's the hard spot to find ^^
<shevy>
For some reason, I have to think longer when I see "def foo bar" than "def foo(bar)" so I prefer the latter
<tshirtman>
i agree
Amirh has joined #ruby
Hanmac has joined #ruby
<Amirh>
hi people
<shevy>
do you use the new -> operator in 1.9.x yet?
<shevy>
My brain is not very happy with it so far, so I try to not use it :\
fayimora has joined #ruby
* tshirtman
didn't do 1.9 yet
<tshirtman>
quite new to ruby
<JonnieCache>
if youre new just learn 1.9
<JonnieCache>
dont encumber yourself with 1.8 thinking
<tshirtman>
well, i'm doing redmine dev
<tshirtman>
plugin*
senny has joined #ruby
<JonnieCache>
ah ok
<tshirtman>
so i learn what i need ^^
yakko has joined #ruby
hukl has joined #ruby
IrishGringo has joined #ruby
zenChild has joined #ruby
<Hanmac>
can i turn a wchar_t character to an ruby string? (there are could also an UTF8 char)
Jake232 has joined #ruby
<linduxed>
hey guys, anyone here using rbenv?
<shevy>
linduxed heya
<shevy>
still having fun with rbenv? :D
<linduxed>
shevy: o/
<linduxed>
shevy: sure am
jxpx777 has joined #ruby
<linduxed>
shevy: noticed that some binaries are not added to the path. cucumber is, but some others arent
jxpx777 has joined #ruby
<linduxed>
otherwise it's fine
<shevy>
hmm
bobby has joined #ruby
asuka_ has joined #ruby
jaywastaken has joined #ruby
jds has joined #ruby
<JonnieCache>
linduxed: yeah im using it
<JonnieCache>
linduxed: you have to run `rbenv rehash` after you install new binaries
<JonnieCache>
thats the only niggle about it
<JonnieCache>
but oyu can fix it with some well placed aliases
<linduxed>
i've done that, but it doesn't seem to add it
<linduxed>
i've done "gem install rspec" for instance
<linduxed>
actually i'm doing it again just for the sake of making sure
<linduxed>
there, installed
<linduxed>
now i'll do "rbenv rehash"
<linduxed>
open up a new terminal...
<tai>
What is considered the canonical standard for formatting Ruby code?
<tai>
stylistically, I mean
<linduxed>
and rspec is not there in shims...
<JonnieCache>
linduxed: hmm obviously you are loading it in .bash_profile correctly?
<JonnieCache>
thats weird
<linduxed>
tai: i don't know if there are that many projects that do code formatting for ruby
<linduxed>
tai: google doesn't give that much
<tai>
I wasn't clear with my question
<tai>
what I mean is, what is the generally accepted style guide for writing Ruby code?
<epaiffe>
How can I crypt the stdin input ? For example, if an user type his password, I don't want to display it on the screen, I wanna see *** or nil
<Hanmac>
burgestrand: because i writing itfrom the C side ... :/
<epaiffe>
thanks
<burgestrand>
Hanmac: yes, but even a wchar_t is just a sequence of bits, isn’t it?
<burgestrand>
granted, it may be more bits than a char, but it feels like it could work converting it to a sequence of chars instead and just passing it to ruby ^^
<davidpk>
if i want to provide Enumerable capabilities over a class, instead of over instances of that class, how do I do that?
demian`_ has joined #ruby
<arturaz>
davidpk, Foo.extend Enumerable
<n3m>
is there some kind of header i can put into a file to get the correct syntax highlighting even if the file doesn't has the language-typic extension?
<davidpk>
arturaz: *tries it*
<n3m>
wrong channel. sry
<burgestrand>
n3m: some editors can pick it up on the shebang of a file
macmartine has joined #ruby
chaitanya has joined #ruby
moted has joined #ruby
stringoO has joined #ruby
grouzen has joined #ruby
eldariof has joined #ruby
cbuxton has joined #ruby
<tshirtman>
http://paste.ubuntu.com/840598/ i'm trying to add an attribute to redmine issues there is probably something i'm doing wrong, as i get an error when i try to use it
<tshirtman>
any idea?
ph^ has joined #ruby
achievbot has joined #ruby
Synthead has joined #ruby
jwmann has joined #ruby
banseljaj has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
<JonnieCache>
tshirtman: post the error as well
stef_204 has joined #ruby
<tshirtman>
JonnieCache: well, it's a dumb "undefined method 'estimated_time_to_completion'"
<gift>
i've got a hex string that i'd like to print as an ascii string. i.e. "41414141" => "AAAA". google is reluctant to give me a straight answer
dark3rdre4ms has joined #ruby
PragCypher has joined #ruby
Sliker has joined #ruby
internet_user has joined #ruby
hukl_ has joined #ruby
<td123>
"%c" % "41".to_i(16)
enroxorz has quit [#ruby]
<td123>
you'll have to modify that, but it should be easy from there :P
<frontendloader>
thin's website actually makes me angry
<canton7>
yeah... it's thing. OK. I get it. Now make it readable
<canton7>
s/thing/thin
<frontendloader>
I can understand having your main page be 'thin', but the docs too? I want to say so many nasty things.
cassarani has joined #ruby
musl has joined #ruby
<frontendloader>
I've never been this angry about software before.
<cassarani>
so say I'm returning JSON from a web service using Array#to_json, should I convert my characters into HTML entities as appropriate?
<Mon_Ouie>
You can just generate the docs yourself though
<cassarani>
in particular, I'm returning a JSON string that has "£" in it at one point - should it be "£"?
Araxia has joined #ruby
<cassarani>
or should JSON not know about HTML entities?
<cassarani>
i.e. should the conversion happen on the server or on the client side?
fayimora has joined #ruby
<canton7>
cassarani, I make the distinction between passing HTML and passing data over JSON. If you're expecting the JS to parse the received value, then it's data, and shouldn't be escaped. If it's just spitting it onto the page, it's HTML, and it should be escaped imo
<frontendloader>
pass it as
<cassarani>
canton7: I agree, the data is being sent to a Backbone.js client app
<cassarani>
which is then displaying it inside an Underscore.js template
<cassarani>
so it sounds like that's when the conversion should happen
<cassarani>
at rendering time that is
rickmasta has joined #ruby
ghanima has joined #ruby
havenn has joined #ruby
<gift>
td123: thats a solid start, can i perform that calculation on the entire string, or will I need to do it on a per-character basis? i can't seem to get the former to work
bwlang has joined #ruby
rtyler has joined #ruby
havenn has joined #ruby
<td123>
no, when I said you have to modify it, I meant that it will only work on a per "2 char" basis
adamkittelson has joined #ruby
gavit has joined #ruby
fallen has joined #ruby
Sliker has joined #ruby
havenn has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
Sliker has joined #ruby
gilesw has joined #ruby
<gilesw>
heya rubiers
adamkittelson has joined #ruby
<gilesw>
i'm looking for some help debugging a library I'm using
<gilesw>
It works fine reading from google apps but when I try and create a user I get this stack http://pastie.org/3375172
mgm7734 has joined #ruby
t0mmyvyo has joined #ruby
stephenjudkins has joined #ruby
caution has joined #ruby
ReachingFarr has joined #ruby
<caution>
what does @ before a variable mean?
auska has joined #ruby
<mackid>
caution: instance variable. different values for every instance of the class
gloomer has joined #ruby
<auska>
Hi! I'm looking for a function like the php ones var_dump() or print_r() on ruby. Which one can i use?
<cassarani>
you can use p
<shevy>
or pp var
<dark3rdre4ms>
yep, 'p' or 'pp'
<cassarani>
though I don't fully remember what those functions do in PHP
<shevy>
but you must require 'pp' before you can use pp
GiambalaGiambala has joined #ruby
<caution>
different values for every instance? so by default variables inside classes are shared between instances?
<heftig>
no
<cassarani>
caution: what other languages are you familiar with?
<heftig>
"normal" variables are local
leoncamel has joined #ruby
<cassarani>
I bet you they'll have the same concept, they'll just call it something different
<caution>
python, php, C
<mackid>
caution: that would be @@, class variables, those are shared with all classes. and what heftig said
<cassarani>
ok, C doesn't have instance variables because it doesn't have classes
<mackid>
shared with all instances, sorry
<ReachingFarr>
Rake has decided that it should extend the Object class with the Rake::DSL module. This causes it to break when I load my code that has a class with a method named 'rule'. Does anyone know how to stop Rake from doing this hateful thing? It even says that global access to Rake::DSL methods is deprecated and yet they sill extend Object!
<cassarani>
but Python has "data attributes" I think
<heftig>
mackid: and all subclasses and their instances
<cassarani>
unless that's not the name
<caution>
is @var the equivalent to self.var?
<heftig>
no, self.var would call a method "var" on self
<cassarani>
caution: do you mean 'self.var' in Python?
<caution>
self.var exists in Ruby?
<caution>
yes
<cassarani>
I don't know Python well enough
Synthead has joined #ruby
<cassarani>
but it sounds like that's the idea, yeah
<cassarani>
every instance of the same class will have its own value for the different @vars that the class defines
xastion has joined #ruby
<cassarani>
class Foo ; def initialize(bar) ; @bar = bar ; end ; end
<cassarani>
a = Foo.new("foo") ; b = Foo.new("bar")
<cassarani>
a will have a value of "foo" for @bar and b will have a value of "bar" for @bar
<ReachingFarr>
Does anyone know how to stop Rake from being a jerk and breaking when I require a class from my project?
rtyler has quit [#ruby]
xplorer00 has joined #ruby
<caution>
is it standard to check if a variable is undefined using if (!var) ?
nfluxx has joined #ruby
<cassarani>
that wouldn't work in Ruby
shadoi has joined #ruby
<pcboy_>
ReachingFarr: task :your_task => :environment do blabla end
<cassarani>
uninitialised variables will throw a NameError
robotmay has joined #ruby
<pcboy_>
cassarani: I'm using defined?
<cassarani>
pcboy_: I was answering caution's question
ElitestFX has joined #ruby
ElitestFX has joined #ruby
<pcboy_>
cassarani: Oh right
<caution>
how about "if (!@var)", is there a difference?
<caution>
I see it in some code where @var can be undefined at that point
<heftig>
undefined instance variables have the value "nil"
<caution>
heh
<heftig>
if defined?(@var)
Hanmac has quit [#ruby]
<heftig>
defined?(@var) # => nil
<heftig>
@var = nil
<heftig>
defined?(@var) # => "instance-variable"
<caution>
"defined?" is some kind of built in function?
<Mon_Ouie>
It's a keyword
<Mon_Ouie>
It could not be defined as a function, other
<Mon_Ouie>
otherwise defined? Foo would raise an exception instead of returning false
<shadoi>
caution: don't ever do that. :) use: unless @var
<Mon_Ouie>
(and it should be method, not function)
<cassarani>
caution: you can either use unless @var, or unless @var.nil?
<cassarani>
use the former if @var is unlikely to be false, use the latter if it could be false
<cassarani>
that's because in Ruby the only falsy values are false and nil
<cassarani>
so when you say "unless @var" that means "unless @var == false || @var == nil"
akem has joined #ruby
akem has joined #ruby
bluOxigen has joined #ruby
ephemerian has joined #ruby
chaitanya has joined #ruby
blueOxigen has joined #ruby
<ReachingFarr>
pcboy_: Close, but I didn't give you enough information to get the correct answer. Turns out I needed to set the TestTask.loader variable to :testrb to stop Rake from loading its stupid Rake::DSL module.
xplorer00 has quit [#ruby]
tvo has joined #ruby
nemesit has joined #ruby
apok has joined #ruby
<caution>
is there a debug function I can use to list the methods of an object?
<caution>
or all the attributes
<canton7>
caution, like object.methods ? ;)
<caution>
yes thanks
<cassarani>
caution: also object.instance_variables to get all the instance variables (unsurprisingly)
<pcboy_>
caution: I like to use the looksee gem too. It adds a nice ls method to your objects.
<mackid>
protip: most stuff in ruby is named what makes sense :P
<canton7>
pcboy_, that looks awesome cheers :)
nerded has joined #ruby
Russell^^ has joined #ruby
axl_ has joined #ruby
<caution>
are methods that end in ?, standard methods that return a boolean?
cjlicata has joined #ruby
<mackid>
yes
colint has joined #ruby
manizzle has joined #ruby
<caution>
and ones that end in ! modify the object?
<mackid>
specifically, they're "more dangerous" than the non-! version. but if there's only one version of the method, then it probably won't have an !, and could still modify the object
<caution>
haha
<canton7>
"potentially unexpected" is another way of interpreting it
<caution>
I hope this wacky language doesn't interfere with my knowledge of other ones
<caution>
I know I'm going to end up typing "elsif" in python all the time after this
<canton7>
it tends to decrease your opinion of other languages imo
mengu has joined #ruby
<nate_h>
is there a way to have gem print its repo?
<nate_h>
that its using?
<mackid>
when i have to go back to c++ I always forget semi-colons...
Sliker has joined #ruby
Skaag has joined #ruby
nobitanobi has joined #ruby
<nobitanobi>
I'm getting a string and I need a Fixnum. How do I convert?
badabim has joined #ruby
<mackid>
nobitanobi: .to_i will probably work
<canton7>
nobitanobi, "string".to_i
stephenjudkins has joined #ruby
<nobitanobi>
ok, thanks guys
kenperkins has joined #ruby
havenn has joined #ruby
<nobitanobi>
ruby converts integer to big int when it overflows
zodiak has joined #ruby
<nobitanobi>
right?
<auska>
Is there any function that if I have a queue check if a var is on it?
baroquebobcat has joined #ruby
ikaros has joined #ruby
<mackid>
auska: if you need to do that, you probably should be using a different data structure
CoverSlide has joined #ruby
<auska>
mackid, which one would you advise me? I need to have on it all the links that i found while crawling a web site...
namidark has joined #ruby
dross_ has joined #ruby
<namidark>
If I have a module Animal and a module Dog and include Dog inside animal, shouldn't I be able to access it via Animal::Dog? or is that a different syntax?
<mackid>
auska: you just need to keep track of all the links you followed, then see if "x" is one of them?
<burgestrand>
namidark: no, include does not do that
<namidark>
burgestrand: hmm is there some way to get that without mucking everything into one module :(?
<burgestrand>
namidark: in essence; classes and modules will namespace constants defined inside them
<burgestrand>
namidark: why would you do that?
<burgestrand>
or, want to do that
bjensen has joined #ruby
<namidark>
burgestrand: keep the module cleaner :\?
daglees has joined #ruby
crankycoder has joined #ruby
<auska>
mackid, yes, i know it but the problem is how to " keep track of all the links you followed" ...
<burgestrand>
namidark: I have no idea what you mean
<namidark>
burgestrand: so instead of having 20 animals as sub modules inside animal, I could jus tinclude each one, and keep their code in a seperate file
lorandi has joined #ruby
<burgestrand>
namidark: you can still keep their code in a separate file, you can reopen modules and classes in ruby
colint has joined #ruby
<mackid>
auska: if you don't care about ordering, you can put them in a hash. then you don't have to worry about duplicates. or you could use an array, and use index("this/url.htm") to determine whether you've seen it before
zommi has joined #ruby
bwlang_ has joined #ruby
skrewler has joined #ruby
gavit has joined #ruby
samsonjs has joined #ruby
<namidark>
burgestrand: OH! so for instance in dog.rb I'd just do module Animal; module Dog; etc?
<burgestrand>
namidark: more or less that’s what that does
AndChat- has joined #ruby
<burgestrand>
namidark: keep in mind Dog won’t include any behaviour from Animal; the only thing affected here is how you access the Dog constant (which is through Animal)
<namidark>
burgestrand: forgot about how ruby does that ;) been to bogged down in rails
<burgestrand>
frontendloader: "super and @value%…"
<burgestrand>
frontendloader: also if you use attr_accessor you might as well just lose the @value and access the ivar through the method "value" instead
jxpx777 has joined #ruby
<frontendloader>
not sure what you meant by that second sentence, but I'm interested to know
PragCypher has joined #ruby
havenn has joined #ruby
airhorns has joined #ruby
danishkhan has joined #ruby
chimkan___ has joined #ruby
dibri has joined #ruby
llaskin has joined #ruby
<llaskin>
what flag do you pass to the ruby executable to force it to ignore warnings?
zakwilson_ has joined #ruby
LMolr has joined #ruby
JanL has joined #ruby
<Mon_Ouie>
-W0
sirdeiu has joined #ruby
<Mon_Ouie>
Though I'd really answer, you fix the code that triggers warnings
<llaskin>
yea i know Mon_Ouie, its a redeclaration warning
<llaskin>
and tbh, i wanted to redeclare it...
sdwrage has joined #ruby
<Mon_Ouie>
Well, you can still change the code
<Mon_Ouie>
Undefining the constant before redefining
Phrogz has joined #ruby
hukl has joined #ruby
Jay_Levitt has joined #ruby
rfloriano has joined #ruby
phantomfakeBNC has joined #ruby
<llaskin>
how do u undefine?
<Mon_Ouie>
Module#remove_constant
<csherin>
also remove_class_variable and remove_instance_variable
<llaskin>
ok cool
<llaskin>
thanks
adamkitt_ has joined #ruby
jgrevich has joined #ruby
ReachingFarr has quit [#ruby]
adamkittelson has joined #ruby
senj has joined #ruby
davidcelis has joined #ruby
thecreators has joined #ruby
axl_ has joined #ruby
alerticus has joined #ruby
colint has joined #ruby
philips has joined #ruby
Husel has joined #ruby
ctp has joined #ruby
pingfloyd has joined #ruby
wroathe has joined #ruby
cyri_ has joined #ruby
<burgestrand>
frontendloader: I mean dropping the @ on @value :)
<burgestrand>
frontendloader: it’ll work because you have defined attr_accessor :value
snearch has joined #ruby
conor_ireland has joined #ruby
kuzushi has joined #ruby
tensai_cirno has joined #ruby
<tai>
So, ruby seems pretty well geared toward metaprogramming, is this really the case?
<tai>
[DSL's and such]
<burgestrand>
tai: yep
<tai>
awesome! even more exciting then
<caution>
what does it mean if a name starts with a colon?
<burgestrand>
caution: it’s a symbol, a special kind of string that is never garbage collected (it stays in memory forever) and is very speedy to compare with
<burgestrand>
tai: sinatra (http://sinatrarb.com/) is a good example of how DSLs are written and used in Ruby
bwlang_ has joined #ruby
shadoi1 has joined #ruby
thecreators_ has joined #ruby
Seppman has joined #ruby
ph^ has joined #ruby
userbard has joined #ruby
adamkittelson has joined #ruby
billy_ran_away has joined #ruby
<tai>
thanks for the link burgestrand, this is quite an interesting read!
<billy_ran_away>
I asked this in #rspec, but there's not very many people there so… I'm trying to spec a serialization class method… and I'm at complete loss as to how to do this… Can anyone point me in the right direction?
<burgestrand>
billy_ran_away: take some value, run it through the serialization method, and look at the end result to make sure it’s what you expect.
<billy_ran_away>
Right, but I need to run a bunch of examples though, so will those different examples be in an example group with a shared context?
<burgestrand>
tai: rspec is also a nice example, but it’s harder to look at the documentation for that to get a feel of how it looks. :)
<billy_ran_away>
Or the different examples really different context that need to go though a shared example?
|bardoe| has joined #ruby
<burgestrand>
billy_ran_away: I’m not sure why you need to nuke your egg when it sounds like you just need a spoon. Can’t you just wrap the different test cases in a describe block?
<billy_ran_away>
Yea but I'm just not sure how to keep it DRY...
<billy_ran_away>
burgestrand: Here's my 2nd attempt...
<burgestrand>
or rather, I see what you’re trying to do
<billy_ran_away>
Well I'm working on the rails gem xml_active, right now it has two separate methods, many_from_xml and one_from_xml, I want to make them both use one method from_xml and test that it can handle all the associations of AR so I need to build examples of each.
<burgestrand>
billy_ran_away: I’m still hesitant to believe you need a shared context at all; for one method on one object it sounds a bit like an overkill… but I guess it could be useful if you need more than one test for each input type. In that case what you have there looks okay to me.
<CannedCorn>
hey guys what exactly happened to the hash implementation on the latest 1.8.7 patch level
<CannedCorn>
does merge! call []= internally for all the key,value pairs that are being passed in, how would i figure out what is going on behind the scenes?
<billy_ran_away>
burgestrand: Well because I want to be handle an array of many AR objects, and just one AR object, so every association test twice, and import test twice
<burgestrand>
CannedCorn: it depends on the ruby implementation; I’d read the C source if you’re into that kind of thing
dazoakley has joined #ruby
pingfloyd has joined #ruby
<CannedCorn>
thanks burgestrand
<burgestrand>
billy_ran_away: what’s wrong with the example you showed us?
<CannedCorn>
one more, if you are passing in an Array as a last argument how do you prevent it from becoming a hash
<billy_ran_away>
burgestrand: I'm looking though the first one… and it's funny I can't remember what was wrong with it now...
<billy_ran_away>
I need to look at the output...
<burgestrand>
billy_ran_away: :p
danishkhan has joined #ruby
axl_ has joined #ruby
jitesh_shetty has joined #ruby
<billy_ran_away>
Oh I didn't like it was going to run all the association tests with just the one include...
<billy_ran_away>
Hence I went to something like the 2nd, but I can't figure how to include shared_examples
<burgestrand>
billy_ran_away: what do you mean; you want to include and run only half of the shared examples?
<burgestrand>
the whole point of shared examples is that it runs all the tests within that shared example ^^
<billy_ran_away>
burgestrand: No I want each individual association test to be run for both contexts...
<billy_ran_away>
err no
bbttxu_ has joined #ruby
<billy_ran_away>
I mean I need to set up different objects for each of those association tests
<billy_ran_away>
so I want different contexts for each...
<billy_ran_away>
I don't know I"m confused, I'm just going to go write some code and come back to the rspec in a minute
<billy_ran_away>
I hate doing that though
<burgestrand>
billy_ran_away: you mean the parameter book/books you pass in when you include the shared examples?
<billy_ran_away>
Well not quite, because that model only has a has_many
<billy_ran_away>
So there's some other models with the other associations that I need to instantiate and then test
<burgestrand>
billy_ran_away: so, if I understand you right, each of those (has_many, has_one, belongs_to) it’s a different model under test?
<billy_ran_away>
so I want to make one of say belongs_to in one context, and then make a bunch in another context and run them though the examples
<billy_ran_away>
burgestrand: Yea
methodfree has joined #ruby
<burgestrand>
billy_ran_away: do you need to write more than one test for each kind?
remink has joined #ruby
remink has joined #ruby
kmurph79 has joined #ruby
<burgestrand>
billy_ran_away: or will the test look the same for each kind (with the exception of the model under test itself)?
<billy_ran_away>
But not necessarily… by that I mean I could just add associations to say the book model and it'd be the same mode in that case
<billy_ran_away>
I don't know, I could see arguments for both ways now… but I'd lean to separate tests for one record and many records of each kind of association
<billy_ran_away>
Just to help isolate failures, this meta programming can get hairy fast
apok_ has joined #ruby
y3llow has joined #ruby
s0ber has joined #ruby
ChampS666 has joined #ruby
ciopte7 has joined #ruby
<burgestrand>
Oh, I think I see now.
<burgestrand>
… again.
<burgestrand>
:p
adeponte has joined #ruby
<robacarp>
exception reentered
<robacarp>
does that mean what I think it means? It raised an exception in a rescue block?
c0rn has joined #ruby
llaskin has quit [#ruby]
<burgestrand>
You have your method thing, that takes either a range of models or just one model — for both of these cases, you want to test that it does the right thing for a model that has: a has_one, a belongs_to, a has_many… etc.
<billy_ran_away>
Make a custom matcher or something like that
<billy_ran_away>
burgestrand: Awesome, thank for helping me think though this shit
<billy_ran_away>
*thanks
<billy_ran_away>
and *through
bwlang_ has joined #ruby
* billy_ran_away
slaps himself
<burgestrand>
billy_ran_away: I didn’t provide you with a solution, but a rubber duck always helps to straighten out your thoughts :)
<billy_ran_away>
burgestrand: Yep, thanks again!
nonotza has joined #ruby
danslo has joined #ruby
<shadoi1>
anyone have the latest rubinius installed?
Mekkis has joined #ruby
<burgestrand>
shadoi: you need something special?
Guest83591 has joined #ruby
manizzle has joined #ruby
josefig1 has joined #ruby
<shevy>
sex
<RubyPanther>
there's an app for that
<shevy>
lol
<shadoi>
burgestrand: I just needed to know how big the interpreter, etc. are
<shadoi>
I'll install RVM later though. :)
<burgestrand>
shadoi: alright :)
danishkhan has joined #ruby
ikaros has joined #ruby
dcl has joined #ruby
Mohan has joined #ruby
Tearan has joined #ruby
<fred>
hi - I'm a vim fan (i.e. I want to keep the keybidnings) - any recommendations for an IDE that's good for quick refactoring? eg extracting methods, renaming variables/methods etc
zomgbie has joined #ruby
<fred>
komodo and textmate (with plugin) seem releavnt, any others I should add to that list?
<shadoi>
fred: vim.
<fred>
in that case, any recommendations for plugins to get those features?
dazoakley has quit [#ruby]
indstry has joined #ruby
bwlang_ has joined #ruby
<shadoi>
there's a vim-ruby/rails thing
<shadoi>
those features are in vim though, just takes some digging to figure out the voodoo.
<fred>
at the moment I do them with :%s/// which is kinda troublesome
<shadoi>
troublesome in that you miss things, or troublesome in that you need to do it across a project or what?
<fred>
hitting variables without hitting similar phrases in comments, dots, spaces, multilines - just regexps seem the wrong tool for the job
Targen has joined #ruby
<shadoi>
never been an issue for me… *shrug*, textmate should fill the gaps though I suppose.
<shadoi>
I just keep the changes granular, and use find/sed in the shell for bigger changes.
coucher has joined #ruby
chimkan has joined #ruby
ryannielson has quit [#ruby]
snearch has joined #ruby
ilyam has joined #ruby
nanderoo has quit [#ruby]
dr_bob has joined #ruby
<Eiam>
how is "01/22/2012" an invalidte date? a="01/22/2012"; DateTime.parse(a).strftime("%m/%d/%Y")
<Mon_Ouie>
There's are only 12 months in a year, not 22
rushed has joined #ruby
<Eiam>
strftime should be dealing with that.. it explicitly says m/d/year
adamkittelson has joined #ruby
<Mon_Ouie>
No, it's in Date.parse
<Mon_Ouie>
You don't pass any format to Date.parse, it assumed DD/MM/YYYY
caili has joined #ruby
<dr_bob>
Eiam: d = DateTime.strptime '01/22/2012', '%m/%d/%Y'
<Mon_Ouie>
strptime allows you to pass a format
<Mon_Ouie>
Like that, yeah
<Eiam>
oh
<dr_bob>
Eiam: strftime is for formatting a DateTime, that does not affect parsing which happens before
namidark has joined #ruby
<Eiam>
right parse is barfing on the bad format
<Eiam>
that im reformatting after its bad
<Eiam>
(since i knew it was bad) yeah, go me. anyway
<Eiam>
thanks..
<namidark>
Is there an elegant way of checking if something is nil, and then checking if empty, without doing a nested if block? unless foo.nil? && foo.empty? is borking when foo is nil
anon117 has joined #ruby
<Mon_Ouie>
You want ||, not &&
<Eiam>
.blank?
<Eiam>
(in rails)
waazzuup has joined #ruby
jingoro has joined #ruby
bwlang_ has joined #ruby
savage-_ has joined #ruby
<namidark>
Mon_Ouie: thanks!
<havenn>
def blank?; respond_to?(:empty?) ? empty? : !self; end
<namidark>
Eiam: yeah I'm in rails :\ ... blank is the same as empty isnt it?
<Aquilas>
Hey guys quick question. I need to pull a bunch of files off of links on a website. Can I use ruby to write a script that will download the files all at once for me?
ilyam has joined #ruby
<RubyPanther>
yes
n8ji has joined #ruby
<Eiam>
maybe not "all at once"
<Aquilas>
well not all at once
<Eiam>
but certainly all of them =)
<Aquilas>
but at least download all the files
danishkhan has joined #ruby
<Aquilas>
Ah great
<Aquilas>
I program but I haven't used ruby yet haha
<Aquilas>
Thanks a lot I'll try and work with this
<Eiam>
there were a few examples provided so
<Eiam>
you should be able to suss out something
hippyphysicist has joined #ruby
davidpk has joined #ruby
colint has joined #ruby
Ferdev has joined #ruby
<zomgbie>
if i wanted to build a small restful web service with sinatra which test framework should i use? i have been really inspired by tom preston werners article on "readme driven development" and wanted to go a step further to use the occasion and really dive into test driven development...
<dr_bob>
Aquilas: I think Mechanize may help you as well.
<Aquilas>
I'll take a look thanks!
<zomgbie>
is bdd "overengineering" within the realm of test driven development? it's a little hard to grasp for me but it somehow *seems* as if this could be really what i am looking for..
enherit has joined #ruby
<burgestrand>
zomgbie: everybody have a different definition of bdd, what’s yours?
<zomgbie>
burgestrand: honestly, I don't have any ... yet ... I just want to write the docs for my API before writing the code ( http://tom.preston-werner.com/2010/08/23/readme-driven-development.html ) but also would like to maybe leverage that with an existing test library to even further the cause... so in short I don't know for sure what I am searching for because I lack the experience (only dabbled with some default unit::test once..)
Azure has joined #ruby
scelis has joined #ruby
asobrasil has quit [#ruby]
<zomgbie>
so opinionated hints on the current best practices are very welcome
<zomgbie>
something like that...
<burgestrand>
zomgbie: in my opinion; as long as you are writing tests for your code, and write your tests first, you’re at least halfway there; the reason you write your tests first is the same rationale for RDD
<burgestrand>
zomgbie: personally, I prefer rspec over minitest (1.9 test::unit), but it’s a personal preference and more of a stylistic choice
Micgo has joined #ruby
hobodave has joined #ruby
<havenn>
hrmm, better practice to use respond_to? rather than rescuing NoMethodError, or just stylistic preference?: class Object; def blank?; begin; empty?; rescue NoMethodError; nil? end end end
<burgestrand>
havenn: use respond_to?
<burgestrand>
havenn: exceptions are not for control flow
fridim_ has joined #ruby
stephans has joined #ruby
<havenn>
burgestrand: that makes sense... thanks! will do
<zomgbie>
burgestrand: thanks - so what is the real difference between rspec and say cucumber? the "english" decided feature descriptions integrated into a "rigid" development process? do i understand this correctly?
<davidcelis>
cucumber is for integration testing
robotmay has joined #ruby
<burgestrand>
zomgbie: cucumber another layer on top of rspec/minitest
<davidcelis>
spec testing really just provides an alternative syntax/ideology to test the same sorts of things as unit tests
<davidcelis>
but cucumber is specifically for testing user interaction with your app
<burgestrand>
zomgbie: so, when using cucumber, you will use rspec/minitest to write your assertions
milkpost_ has joined #ruby
<havenn>
class Object; def blank?; if respond_to?(:empty?); empty?; else; nil? end end end #=> Less fail** =P
<milkpost_>
is there a way to make ruby evaluate an expression like "5/10" but make it use floats to do it?
<milkpost_>
will I have to split and then convert things to floats?
bwlang_ has joined #ruby
<zomgbie>
davidcelis, burgestrand: I get it now, cucumber is just "topping" on rspec/minitest/etc for integration testing.. so i've got to get my definitions right (still don't know exactly what unit testing, functional testing differentiates... will fix that now :))
<havenn>
milkpost_: hrm, you mean like?: require 'mathn'
<zomgbie>
thanks in any case!
<burgestrand>
zomgbie: frankly, all the frickin' terms confuse me as well, not to mention that every single person has a different opinion on what is what
apok has joined #ruby
<milkpost_>
havenn: yes, thank you
lorandi has joined #ruby
<zomgbie>
burgestrand: that feels good to hear, i keep struggling for some years now %-) will set that straight once and for all as i think especially when building a webservice the whole tdd thing can be really satisfying and useful.
rudyl313 has joined #ruby
colint has joined #ruby
<milkpost_>
havenn: where can I find out more about this library, ruby-doc is kinda lame about explaining what it all does
<burgestrand>
zomgbie: personally, when building web applications, I write tests that simulate user behavior with capybara and rspec (and sometimes cucumber on top of that, sometimes just capybara and rspec themselves), and then I write tests for my models (the business logic) in addition to that
<zomgbie>
burgestrand: thanks for the pointers, i will check out capybara as well! i was already getting a little depressed because of the whole issue, this helps - thanks a lot :)
<burgestrand>
Then there’s also controller tests and view tests; I don’t do either of those. Have had my fair share of cleaning up after other peoples’ applications which use them two and a few other ones and it always brings issues for me with little benefit. Keep in mind this is my opinion; some people are bound to think I’m a moron for thinking like this and that view tests are the shit.
c0rn has joined #ruby
<burgestrand>
zomgbie: and a final note about readme driven development; the idea is to think of what you want to do before writing code. to have a plan, more or less.
nerded has quit [#ruby]
<zomgbie>
burgestrand: yeah exactly what i'm aiming for. getting rid of that vague idea thing and really be sure *before* beginning to code.
<mikepack>
Who knows what object oriented programming is?
colint has joined #ruby
Axsuul has joined #ruby
ctp_ has joined #ruby
Axsuul has joined #ruby
ctp- has joined #ruby
Axsuul has joined #ruby
_obiJuan has joined #ruby
ctp has joined #ruby
<yoklov>
frontendloader, interesting, that helps. thanks
<yoklov>
mikepack: probably most of the people here to various extents. what's your question?
<mikepack>
yoklov: My question is: What is OOP :) (I'm trying to gather opinions/takes)
lorandi has joined #ruby
yfeldblum has joined #ruby
<mikepack>
yoklov: It's quite generic, but I'm trying to draw out discrepancies be common practice and Alan Kay's vision of OOP
<yoklov>
i'd say that it's a programming technique/paradigm where the execution of your program is some sort of model.
<banisterfiend>
mikepack: so thta you can be condescending and start pontificating when people get it wrong? :)
<yoklov>
or models some sort of situation.
<yoklov>
something like that.
<mikepack>
banisterfiend: haha, like you just did?
S1kx has joined #ruby
schlecht has joined #ruby
<mikepack>
banisterfiend: If you must know, the opposite. I'm trying to figure out how we can produce better code through OOP
hippyphysicist1 has joined #ruby
QaDeS has joined #ruby
<frontendloader>
at the most basic level, to me, OOP is the blissful marriage of data structures with functions
<schlecht>
Oh dear.
<mikepack>
ie. Is an object supposed to contain all the functions it can ever perform?
Illiux has joined #ruby
<frontendloader>
that's up to the compiler/interpreter
<mikepack>
frontendloader: Good explanation. How are the data structures/functions supposed to be joined?
<mikepack>
frontendloader: I guess a typical answer would be "at class definition"
<mikepack>
I'm wondering if anyone ever joins structure with function outside of class definition.
<frontendloader>
functions are aware of the instance which they're a member of, selfness
<yoklov>
mikepack, are you familiar with paradigms other than oo?
<mikepack>
yoklov: Sure, which ones specifically?
<yoklov>
functional programming is very much about joining data structures with functions in a manner which has no classes whatsoever.
<frontendloader>
if oop is marriage, functional programming is the consummation
<yoklov>
lol
h4mz1d has joined #ruby
<mikepack>
yoklov: Data structure are very basic in functional programming, no?
<yoklov>
what do you mean by that
<mikepack>
yoklov: I mean to say that if you refer to a particular data structure, it doesn't also contain actions it can perform.
<yoklov>
you don't organize your code that way.
chimkan has joined #ruby
<yoklov>
your data structures don't perform actions on itself.
<yoklov>
*themselves
<yoklov>
you write functions which perform actions on them.
<mikepack>
yoklov: You pass data structures to atomic functions which manipulate your data
vraa has joined #ruby
<mikepack>
yoklov: Yeah, that's my understanding
<yoklov>
it depends what you mean by atomic?
<yoklov>
often your fucntions will just be compositions of other functions.
<yoklov>
the largest difference between FP and OO is that with OO you think in terms of interacting objects, and with FP you think of it in terms of the flow of your data.
<mikepack>
yoklov: What manages state in functional languages?
<yoklov>
you pass the state to the next function.
<mikepack>
yoklov: Your state is represented as basic data structures? A hash for instance.
<schlecht>
yoklov: Enjoying your book?
<yoklov>
mikepack: in a functional language if you have { :foo => :bar }, and you set :foo to be something else, the actual value of the object never changes, but instead you get a new hash which contains the new value.
<yoklov>
schlecht, yeah, it's pretty awesome. needed a good reference for ruby.
<schlecht>
yoklov: Cool
<mikepack>
yoklov: Is that a strict requirement? That the object can't be manipulated.
<yoklov>
it depends on the language.
<yoklov>
in "pure" functional programming, yes.
kmurph79 has joined #ruby
<yoklov>
in something like scheme, or lisp (whcih I'm more familiar with), no
<mikepack>
yoklov: When you say functional programming is about joining data structure with functions, what do you mean? Data is just passed to functions which return data.
<schlecht>
yoklov: You're familiar with java!
colint has joined #ruby
<yoklov>
mikepack: I mean that the functions which manipulates the data structure will likely be in the same file as the code which defines the data structure?
<yoklov>
FP is very much about thinking about your code in terms of its data structures
Gekz has joined #ruby
<yoklov>
schlecht, lol, I was quite offended when whoever said that said that. I've written much more lisp than java :p
<schlecht>
It's very much about thinking about your code in terms of space, where procedural thinks in terms of time. I'd say.
<schlecht>
yoklov: I said that. We spoke at length in query about how I hadn't showered in weeks.
denom has joined #ruby
<yoklov>
oh that was you, haha
<yoklov>
it was extremely late
<schlecht>
I was extremely baked.
stephenjudkins has joined #ruby
<yoklov>
i could sorta tell
<yoklov>
i might have been sorta high? i don't know. i don't remember.
<schlecht>
)
supergiantrobot_ has joined #ruby
<yoklov>
Anyway, mikepack: if you think the fact that data structures don't include functions in FP somehow less makes it less of a joining of functions and data structures, I recommend you go write some functional code.
Sivart has joined #ruby
thecreators_ has joined #ruby
<yoklov>
(and in fact, a lot of times you will have a function in your data structure, however it will be part of the data, and not part of the function which manipulates the data)
<mikepack>
yoklov: I've written a little functional programming, mostly trivial stuff.
<yoklov>
write a larger program
<mikepack>
That makes no sense
<mikepack>
"I've written a little functional programming"...
<mikepack>
Anyway, I guess I'm intrigued by concepts which simplify the idea of objects in OO languages
<yoklov>
have you written much javascript?
<mikepack>
As opposed to objects which contain everything they could ever perform
<mikepack>
Yeah, a ton of JS
<yoklov>
i mean function prototypes are certainly a simlification of objects/classes.
<Asher>
how do you figure?
<mikepack>
Are you alluding to the idea that objects in JS are simple to create literally?
<yoklov>
not at all
<yoklov>
i'm talking about implementing the object systems
<yoklov>
function prototype is, for all intents and purposes, a hashtable of functions and values.
<mikepack>
objects in JS can grow quite monolithic
<yoklov>
every language has bad code written in it.
<yoklov>
classes and objects have complicated semantics (access, overriding, etc). classical inheritance is much more difficult to implement than prototypal inheritance
<mikepack>
Interesting, why do you say that? They're both just modifying the lookup table.
alx- has joined #ruby
<Asher>
this sounds to me like a bunch of talk
<mikepack>
That's all it is :)
<Asher>
they're two different models not sure why one is easier/harder than the other
* yoklov
isn't talking about in terms of use
<schlecht>
Asher: What were you doing before ruby?
<Asher>
i do a bunch of C/Obj C in addition to ruby
<schlecht>
Was that before ruby?
<Asher>
before ruby would be i guess C, Obj C, Javascript, PHP
<Asher>
but i've been doign ruby a while now
snip_it has quit [#ruby]
c0rn has joined #ruby
Spockz has joined #ruby
<mikepack>
yoklov: I think that statement needs a context. In JS it's much easier to do prototypal inheritance than it is classical.
<mikepack>
In ruby I would say it's the opposite, or at least less obvious
<mikepack>
my_object.extend SomeModule might be considered prototypal inheritance
bwlang has joined #ruby
<mikepack>
yoklov: thanks for entertaining my questions :) I'm just shootin the shit
<yoklov>
a while ago i extended a toy scheme to support prototype based inheritance which was fairly easy (add a object primitive, add functions for get, set, delete, etc. make it have a prototype). whenever i've tried to implement a classical object system, the only way i've been able to think about doing it was basically "do a prototype based one and nerf it"
TheTFEF has joined #ruby
Indian has joined #ruby
<yoklov>
and maybe that's how its done.
<yoklov>
idk, classical inhertiance just has a lot of complicated semantics not present in prototypes
<yoklov>
which is why i say the prototype one is simpler.
<Asher>
i don't see why one is ahrder than the other
<Asher>
they're both just ways of structurig the lookup chain
wyhaines has joined #ruby
<mikepack>
Maybe because classical systems need support of the compiler/interpreter
<yoklov>
well i was writing the interpreter
<Asher>
as opposed to?
<mikepack>
What i mean to say is that you can't build a true classical system without the compiler/interpreter
<yoklov>
Asher: classes tend to have access modifiers, for one thing
<mikepack>
You can build a makeshift classical system through protypes
<mikepack>
prototypes*
<mikepack>
JS is a prime example
<mikepack>
All classical implementations in JS use prototypes to mimic the lookup table
<yoklov>
Asher, you don't think that prototypes are a more basic system than prototypes?
<Asher>
to me prototypical or classical inheritance are both just ways of structuring the lookup chain