apeiros_ changed the topic of #ruby to: programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails
dbgster has joined #ruby
neurodrone has joined #ruby
liluo has joined #ruby
thisisme11 has joined #ruby
<thisisme11>
...
luckyruby has joined #ruby
vanmik has joined #ruby
ByteCrunch has joined #ruby
Paradox2000 has joined #ruby
evilgeenius has joined #ruby
<evilgeenius>
Is there an accessor class function, such as attr_accessor, that can create a variable that can only be accessed from within the object?
<fowl>
attr_accessor :x ; private :x, :x=
<fowl>
you could write a method to do that and call it i_love_fowl
<dbgster>
when you have 2 models that have has_and_belongs_to_many (both referencing each other), this means you can add to either models proxy class?
<evilgeenius>
or :fowl_is_stalking_me_please_help
<fowl>
;)
Bardosity has joined #ruby
<fowl>
dbgster: models and proxies are the worry of the proletariat. #rubyonrails
<dbgster>
fowl: ?
<fowl>
/join
<shevy>
dbgster he says that the channel here is about ruby, not a specific framework like yuor question.
plato has joined #ruby
plato has joined #ruby
Rishi_ has joined #ruby
burns180 has joined #ruby
Eiam has joined #ruby
sbanwart has joined #ruby
kevinbond has joined #ruby
pu22l3r has joined #ruby
<evilgeenius>
fowl: What's the best way of doing that? or just using instance variables?
<evilgeenius>
scrap the "or"
<fowl>
evilgeenius: I have a small test for you to pass first. class Person; attr_writer :name; private :name=; end how would you call the name= method?
<evilgeenius>
fowl: self.name =
<shevy>
how would that even work man
ScottNYC has joined #ruby
Sailias has joined #ruby
Zolrath has joined #ruby
<evilgeenius>
shevy: ?
<shevy>
evilgeenius go show code that works
<shevy>
"self.name =" does not work
banisterfiend has joined #ruby
<evilgeenius>
shevy: it does if there is a attr_writer
<shevy>
did you test it at all?
<evilgeenius>
shevy: yes, just now.
<shevy>
k could you show me your code please?
<evilgeenius>
it worked fine
<evilgeenius>
run this : class Person; attr_writer :name; private :name=; def hi ; self.name="shit" ; end ; end ; p = Person.new ; p.hi
<banisterfiend>
shevy: hey shevegen
<banisterfiend>
evilgeenius: Yeah self.name= works even if it's private
<banisterfiend>
evilgeenius: it's an exceptino to the rule
<banisterfiend>
exception
<evilgeenius>
banisterfiend: It doesn't matter if it's private because I'm using it inside the object.
<banisterfiend>
evilgeenius: it does matter because you're accessing it through an explicit receiver
waxjar has joined #ruby
mickn has joined #ruby
<banisterfiend>
evilgeenius: the access rules apply to explicit receivers :)
<banisterfiend>
NoMethodError: private method `name' called for #<Hello:0x0000010105f8a0>
<evilgeenius>
banisterfiend: that's unexpected.
<banisterfiend>
evilgeenius: no, it's expected when you understand that the access rules apply to explicit/implicit receivers
sedai has joined #ruby
<banisterfiend>
evilgeenius: anyway what was your question
<evilgeenius>
banisterfiend: Being able to access a method only from the outside is unusual.
rkinyon has joined #ruby
<fowl>
sorry i stepped away
<evilgeenius>
banisterfiend: it doesn't seem to go along with OO ideas
<banisterfiend>
fowl: smoking to keep thin?
<banisterfiend>
evilgeenius: what was your question anyway?
lkba has joined #ruby
nesoi has joined #ruby
<banisterfiend>
evilgeenius: ping
<evilgeenius>
banisterfiend: Whats the best way to access an instance variable from within a class that you don't want to be pubkic.
<evilgeenius>
Just use @? or just create private accessors?
<banisterfiend>
evilgeenius: it depends, do you always want just direct access to the ivar? or might you want more sophisticated access in the future?
<banisterfiend>
evilgeenius: if all you want is direct access then use the @ivar
looopy has joined #ruby
zandt has joined #ruby
<banisterfiend>
evilgeenius: but the advantage in using a method instead is that if you later choose to extract another class out of your current one, it's trivial to make that accessor method delegate to the other class instance instead of the ivar in your class
<evilgeenius>
yes good point
cameron_ has joined #ruby
<nesoi>
hello, I have something like: start_time = Time.utc(2003); puts start_time; That prints out the date as expected. Then I have a database column called last_order_entered defined as type datetime. If I do Last_orders.create(:last_order_entered => start_time) and then retrieve it with start_time = Last_orders.first (there's only one record), and do puts start_time, I get #<Last_orders:0x1da02d0>. What am I doing wrong?
<evilgeenius>
banisterfiend: so is it best to use attr_accessor :x and private :x, :x= or create the methods manually? whats normal?
<banisterfiend>
evilgeenius: either is fine, they're equivalent actually. However, many people dont even bother to make things 'private' :)
<nesoi>
any hints?
pu22l3r has joined #ruby
<evilgeenius>
nesoi: do puts start_time.last_order_entered
<evilgeenius>
nesoi: start_time is a Last object, so you need to call the last_order_entered method on it
[[thufir]] has joined #ruby
<evilgeenius>
nesoi: sorry, start_time is a Last_orders object.
ed_hz_ has joined #ruby
nikhil_ has joined #ruby
<evilgeenius>
nesoi: sorted it?
<nesoi>
evilgeenius : thanks, that worked!
Drewch has joined #ruby
<nesoi>
evilgeenius : so my next question is, any idea how to create a datetime in this format? 2009-04-01T23:48:34.000Z
<evilgeenius>
nesoi: if you're using rails with ActiveRecord then it's quite strange that you have a Last_orders object.
mickn has joined #ruby
<evilgeenius>
nesoi: you want to output to the screen in that format?
<nesoi>
evilgeenius: I'm processing input data and want to be able to resume from where I let off
cameron_ has joined #ruby
<nesoi>
no, that's how the data comes to me, so I need to either convert the Time.utc to that format, or convert that to Time
<nesoi>
or can I do a string compare on dates in that format?
<evilgeenius>
nesoi: You could try using the Time.parse("2009-04-01T23:48:34.000Z") method to try converting the string into a Time object. Time.parse is in rails. Are you using rails?
<nesoi>
no, but I could include that if I know what to require
<nesoi>
or I could just store the string as a string and compare strings
<nesoi>
could I compare them as strings? they should stort so that the later date is always greater no?
banister_ has joined #ruby
<evilgeenius>
nesoi: that method is in the activesupport gem
<nesoi>
oh I included that
<nesoi>
that worked!
cameron_ has joined #ruby
pu22l3r has joined #ruby
<evilgeenius>
an alternative is to use regular expressions to extract the bits you need from the string and then pass it into Time.mktime(year, month, day, hour, minutes)
<evilgeenius>
nesoi: Time.parse can give you unexpected results though. You should test it in edge cases if you're gona use it.
Abhinav1 has joined #ruby
magic_hat has joined #ruby
<evilgeenius>
nesoi: check that it's getting the month and days field the right way round
<nesoi>
it is ATM... what if it wasn't?
Teddy2steper has joined #ruby
<magic_hat>
Hi all. Can anyone think of how to write a regex that identifies a target phrase only if it's not enclosed by an anchor tag? this is killin' me!
Abhinav1 has joined #ruby
<evilgeenius>
nesoi: then don't use it
<nesoi>
:)
<evilgeenius>
nesoi: I use regular expressions to extract fields from the time string. e.g. "2009-04-01T23:48:34.000Z".match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/)
<nesoi>
yeah, I have to learn regex. I never really got it
<evilgeenius>
run this : match = "2009-04-01T23:48:34.000Z".match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/) ; p match[1], match[2], match[3], match[4], match[5]
PragCypher has joined #ruby
<evilgeenius>
nesoi: it's definately worth investing some time to learn them
Paradox2000 has joined #ruby
<nesoi>
yeah, I know... but I'm trying to learn a bit of ruby first... :)
CheeToS has joined #ruby
<nesoi>
nice
waxjar has joined #ruby
<evilgeenius>
nesoi: One key to appearing a better programmer than you really are is to know your libraries. Or even better, know how to find decent libraries. I always look here to find the best tools : https://www.ruby-toolbox.com/
Paradox2000 has joined #ruby
nari has joined #ruby
S2kx has joined #ruby
nikhgupta1 has joined #ruby
jhowarth has joined #ruby
dbgster has joined #ruby
BHensley has joined #ruby
h4mz1d has joined #ruby
nesoi has joined #ruby
dv310p3r has joined #ruby
CannedCorn has joined #ruby
shtirlic_ has joined #ruby
davidcelis has joined #ruby
albemuth has joined #ruby
mikepack has joined #ruby
wyhaines has joined #ruby
marknyc has joined #ruby
pastjean has joined #ruby
TESTKEYz has joined #ruby
pastjean has joined #ruby
adeponte has joined #ruby
liluo has joined #ruby
td123 has joined #ruby
thisisme12 has joined #ruby
mikeric has joined #ruby
andrewhl has joined #ruby
looopy has joined #ruby
banisterfiend has joined #ruby
pac1 has joined #ruby
theRoUS has joined #ruby
machine2 has joined #ruby
luxurymode has joined #ruby
raluxgaza has joined #ruby
FACEFOX has joined #ruby
looopy has joined #ruby
sedai has joined #ruby
shtirli__ has joined #ruby
CannedCorn has joined #ruby
williamcotton has joined #ruby
TESTKEYz has joined #ruby
<arphen>
anyone good with webdev?
<arphen>
i'm having an issue with my own code and i'm too stupid to find it on google:
<arphen>
does the occurence of "$(this).serialize();" imply that i'm using jquery code?
<evilgeenius>
There is also a glassfish gem that you might find useful
adamkittelson has joined #ruby
<lukeholder>
What's the diff?
<evilgeenius>
lukeholder: I can't remember
zandt has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
simpleharmonicmo has joined #ruby
<evilgeenius>
lukeholder: They are distinct in the way they work though
<lukeholder>
Ok
adamkitt_ has joined #ruby
ghosTM55 has joined #ruby
<arphen>
evilgeenius, thing is i am not including jquery... is there any other context $(this).serialize() could work?
<evilgeenius>
arphen: ask in the #jquery irc room
<arphen>
also: do you feel cool using "lmgtf
<evilgeenius>
arphen: no, i regretted it instantly
<arphen>
you might as well have said nothing thank you
<evilgeenius>
arphen: do you feel cool telling us you are too lazy to search google?
c0rn has joined #ruby
yoklov has joined #ruby
<arphen>
evilgeenius, i said i am too stupid to formulate a question
<arphen>
how the hell do you google for "$(this)" without a billion irrelevant results
kevinbond has joined #ruby
<banisterfiend>
evilgeenius: how come a genius cant spell 'genius' correctly
<banisterfiend>
or are you an iconoclastic genius and play by your own rules? :P
lukeholder has joined #ruby
<evilgeenius>
banisterfiend: You don't need rules where im going, and am.
jwang has joined #ruby
havenn has joined #ruby
<banisterfiend>
evilgeenius: mexico?
apucacao has joined #ruby
h4mz1d has joined #ruby
chimkan has joined #ruby
<evilgeenius>
banisterfiend: le'ts just say... I am the moon.
<evilgeenius>
*let's
<banisterfiend>
ah right
<banisterfiend>
mental asylum ;)
<evilgeenius>
Is it ok for a private method to call a public method?
<banisterfiend>
evilgeenius: Yeah
banisterfiend has joined #ruby
whh has joined #ruby
drake10 has joined #ruby
gen0cide_ has joined #ruby
zandt has joined #ruby
yoklov has joined #ruby
krz has joined #ruby
CannedCorn has joined #ruby
_ack has joined #ruby
<_ack>
Hello. sending mails using gmail's smtp servers can be done on ruby 1.9.3?
robbyoconnor has joined #ruby
SegFaultAX has joined #ruby
<td123>
smtp is a protocol independent of any language
banisterfiend has joined #ruby
lukeholder has joined #ruby
jphpsf has joined #ruby
Fezzler has joined #ruby
adeponte has joined #ruby
<_ack>
td123, I know. The thing is ruby is throwing some errors with I try to send mails with Net::SMTP, complaining about STARTTLS. But when I do .enable_starttls It segfault.
<_ack>
when*
gabeh has joined #ruby
<td123>
it segfaults? you need to file a bug
<_ack>
yes. I will do that
Sailias has joined #ruby
<banisterfiend>
_ack: run it in gdb to find the place it's segfaulting
<senthil>
I don't think its rspec syntax, have used expect before with no error
ghosTM55 has joined #ruby
<maahes>
I'm using rvm, and I'd like to not have to add each gem I use individually to my rc, for each different version of ruby. Is there a catchall command I can use?
wilmoore has joined #ruby
<senthil>
Its not what's inside expect block either, same error for diff. body also
ghosTM55 has joined #ruby
<maahes>
also, how do I add my system ruby into rvm as it's default? So I can switch back to it.
<senthil>
rvm use system --default
ringotwo has joined #ruby
burns180_ has joined #ruby
burns180 has joined #ruby
Apocalypse has joined #ruby
khannz has joined #ruby
burns180_ has joined #ruby
_|christian|_ has joined #ruby
kstephens has joined #ruby
stephenjudkins has joined #ruby
NotreDev has joined #ruby
burns180 has joined #ruby
<NotreDev>
is there a flag i can set to not return the result of my most recent command on irb? it's about to return a hell of a lot of data
Drewch has joined #ruby
wenbert has joined #ruby
DarthGandalf has joined #ruby
<banisterfiend>
NotreDev: not in irb, but you can in pry
<HINS>
kah: You'll need to learn automatons if you really want to understand regular expressions...
<kah>
also, quick question, this isn't really the place but i don't know where else to go, when i go to log into IRC it mistakes my identify for kahuna and not kah, suggestions??
<seanstickle>
And if you really want to understand automatons, you'll need to understand logic
<seanstickle>
So read up on Aristotle too
<kah>
i can do that
<seanstickle>
Or, you could just take it one step at a time
<kah>
what book would outline automatons?
<seanstickle>
And read the Regex book
<kah>
the mastering reg ex?
<seanstickle>
Yeah
<kah>
i just picked up a book called reg expressions in 10 mins
<kah>
ill start with that
<kah>
and then hit up your book
<kah>
that you suggested
<seanstickle>
Sounds like a plan
<seanstickle>
Also, check out #regex, where all us regex folks hang out
<kah>
ah nice
<kah>
i will for sure
<kah>
any idea how to solve my other problem w my irc identity?
<kah>
maybe i'll just create a new one..
c0rn has joined #ruby
<seanstickle>
My knowledge of IRC extends to knowing how to type in stuff and hit enter
<seanstickle>
You could try the #help channel
<kah>
kk cool thanks
ilyam has joined #ruby
ipoval has joined #ruby
ipoval has quit [#ruby]
psylinse has joined #ruby
io_syl has joined #ruby
<maahes>
to include a gem dir in my source do I just have to do something like export PATH=$PATH:$HOME/rvm/path/to/particular/ruby/gem/dir/* for all subdirs?
<maahes>
causes my shell to spit out: "string not in pwd: ../
sandGorgon has joined #ruby
<maahes>
"
* maahes
watches the crickets.
lampe2 has joined #ruby
wenbert_ has joined #ruby
<lampe2>
hey i generated a gem with bundler and now i wanne test the script how i do it?
<sandGorgon>
lampe2: set your GEM_PATH and GEM_HOME to the path of the local gem and you can use your scripts
bier has joined #ruby
kah1 has joined #ruby
kah has joined #ruby
kah_ has joined #ruby
maletor has joined #ruby
khannz has joined #ruby
artm has joined #ruby
c0rn has joined #ruby
ipoval has joined #ruby
khannz has quit [#ruby]
ben225 has joined #ruby
ipoval has quit [#ruby]
wenbert_ has joined #ruby
Karmaon has joined #ruby
MrGando has joined #ruby
wolflee has joined #ruby
burns180 has joined #ruby
advorak has joined #ruby
greenarrow has joined #ruby
nfluxx has joined #ruby
Guest53287 has joined #ruby
a_a_g has joined #ruby
cameron_ has joined #ruby
bounce has joined #ruby
robacarp_ has joined #ruby
wolflee has quit [#ruby]
JohnBat26 has joined #ruby
nikhil_ has joined #ruby
DiseaseHF has joined #ruby
DiseaseHF has quit [#ruby]
Morkel has joined #ruby
x0F_ has joined #ruby
wilmoore has joined #ruby
Eric_HOU has joined #ruby
banisterfiend has joined #ruby
TESTKEYz has joined #ruby
cameron_ has joined #ruby
Divinite has joined #ruby
MrGando has joined #ruby
nemesit has joined #ruby
moshee has joined #ruby
nemesit|osx has joined #ruby
yxhuvud has joined #ruby
nikhil___ has joined #ruby
lan has joined #ruby
wedgeV has joined #ruby
CheeToS has joined #ruby
mdw has joined #ruby
aknewhope has joined #ruby
lan has quit ["Leaving"]
hooper has joined #ruby
wedgeV has joined #ruby
mneorr has joined #ruby
maletor has joined #ruby
zakwilson has joined #ruby
jmfcool has joined #ruby
zakwilson has joined #ruby
Banistergalaxy has joined #ruby
Banistergalaxy has joined #ruby
regedarek has joined #ruby
Indian has joined #ruby
kremiak has joined #ruby
looopy has joined #ruby
banisterfiend has joined #ruby
senthil has joined #ruby
shruggar has joined #ruby
zommi has joined #ruby
dzhulk has joined #ruby
ph^ has joined #ruby
danishkhan has joined #ruby
n1x has joined #ruby
nikhgupta has joined #ruby
cha1tanya has joined #ruby
ephemerian has joined #ruby
artm has joined #ruby
jrwesolo has joined #ruby
sleetdrop has joined #ruby
luoluoluo has joined #ruby
dekroning has joined #ruby
cHarNe2 has quit [#ruby]
shruggar has joined #ruby
pi3r has joined #ruby
LMolr has joined #ruby
simao has joined #ruby
shruggar has joined #ruby
headius has joined #ruby
jrwesolo has joined #ruby
jrwesolo has quit [#ruby]
lobolars has joined #ruby
mafolz has joined #ruby
trivol has joined #ruby
johndbritton has joined #ruby
giurik has joined #ruby
<giurik>
CiaO a TuTtO iL CHaN......... AVE Lux. 666
<giurik>
ciao
<giurik>
!list
blacktulip has joined #ruby
ukwiz has joined #ruby
francisfish has joined #ruby
schaerli has joined #ruby
mfridh has joined #ruby
acd has joined #ruby
<acd>
/mames
<acd>
/names
wookiehangover has joined #ruby
pithagora has quit [#ruby]
mdw has joined #ruby
BiHi has joined #ruby
simao has joined #ruby
Divinite has joined #ruby
<acd>
/names
elhu has joined #ruby
cha1tanya has joined #ruby
d3vic3 has joined #ruby
karbonick has joined #ruby
pp01bit has joined #ruby
banisterfiend has joined #ruby
TaTonka has joined #ruby
workmad3 has joined #ruby
apeiros_ has joined #ruby
raluxgaza has joined #ruby
nemesit has joined #ruby
maasha has joined #ruby
nikhgupta1 has joined #ruby
batmanian has joined #ruby
<maasha>
Hello. I am playing with RubyInline. How can I raise my own errors and not ruby's? -> rb_raise(rb_eRuntimeError, "row out of range: %d >= %d\\n", row, rows);
nesoi has joined #ruby
iocor has joined #ruby
<nesoi>
so if I have a hash where I need to sort at the 2nd level, what's the correct way? It's like response.orders and I want to sort each order by one of the many keys at that level. I tried response.orders.sort_by{ |orders| orders[:purchase_date] }; it doesn't complain but it also doesn't work
<apeiros_>
nesoi: you know that sort_by does not do in-place sorting, but returns a new array, which is sorted?
<apeiros_>
i.e., you must assign the result and use that
<maasha>
sort_by!
<elhu>
use sort_by! if you want to sort in place
<banisterfiend>
maasha: get the constant
regedarek has joined #ruby
<fowl>
nesoi: hash.sort_by { |key, value| value[:purchase_data] } the
karbonick has quit [#ruby]
<elhu>
nesoi: as a general rule, methods aren't' performed in place but return a new instance, and methods finishing by ! are 'destructive', since they change the object the method is called on
<fowl>
if it is |orders| I think they get sent as [key, value] so you'd use orders[1][:key]
<fowl>
(i think)
<nesoi>
elhu : so I need to do response.orders = response.orders.sort_by{ |orders| orders[:purchase_date] } ? (assuming that would be the right sort)
<nesoi>
fowl I don't understand the value. I want to sort each record by that key descending
<maasha>
banisterfiend: something like rb_const_get(MyError, "ID")
Ammar01 has joined #ruby
banister_ has joined #ruby
<elhu>
nesoi: yes, or simply response.orders.sort_by!{ |orders| orders[:purchase_date] }
<elhu>
nesoi: ok, I would have told you to go check out scopes otherwise
<nesoi>
fowl: there are lots of keys though, like 30
<nesoi>
for each record
<maasha>
banister_: I have a class MyError < StandardError; end - so I can use rb_const_get(MyError, "ID") - though I don't really know what to do with the "ID" part.
<fowl>
nesoi: i'm just saying
<fowl>
try that in irb, see the output
<fowl>
then run {a: 10, b: 5, c: 2}.sort_by { |key| puts "#{key}"; key[1] }
visof has joined #ruby
visof has joined #ruby
d3vic3 has joined #ruby
<banister_>
maasha: rb_intern("YourConst")
jonteru has joined #ruby
Shrink has joined #ruby
<nesoi>
fowl : I don't understand the 1st one. what's the extra value at the end doing?
Shrink has joined #ruby
<maasha>
banister_: hm, not quite there -> rb_raise(rb_intern("MyError"), "raising my own error");
<fowl>
nesoi: the value is what you're sorting by, silly
<banister_>
maasha: bitch
<fowl>
puts returns nil, it was just there to show you how the vars come in
<fowl>
nesoi: the sort only cares about the return value from the block so you could have other logic in there if you want, or rand(1000) or anything really
<maasha>
banister_: right. that will do nicely. ty
roolo has joined #ruby
jakebaek has joined #ruby
srnty has joined #ruby
<fowl>
banister_: you ever seen someone raise an exception like `raise SomeException.new("stupid reason")`
ephemerian has joined #ruby
<banister_>
fowl: better to do: SomeException.exception("stupid reason") iirc
zeninfinity has joined #ruby
TaTonka has quit [#ruby]
<fowl>
why not raise SomeException, 'blah'
<banister_>
fowl: that works too, but #exception works with both classes and objects and it has the advantage in copying other exceptoin attributes (if it's an instance)
<banister_>
iirc
<nesoi>
fowl I'm still not quite getting it. those 2 sorts you posted didn't change the order, but if I do a = {a: 10, b: 5, c: 2}; a.sort_by {|a| a[1]} it does print it out in order by increasing value
stefanp has joined #ruby
stefanp has joined #ruby
<fowl>
nesoi: those two sorts i posted werent to fix your problem it was to explain how when you give th block 1 var you get [key, value] pairs ie [:a, 10], [:b, 5] which is why you use a[1] and not just a
<workmad3>
fowl: I prefer hsh.sort_by {|k,v| v} personally
<fowl>
workmad3: i pasted that too and he ignored it
<fowl>
why try?
<workmad3>
oh, didn't notice that :/
flou has joined #ruby
iocor has joined #ruby
<nesoi>
hmm.. well response.orders.sort_by!{ |orders| orders[:purchase_date] } still isn't sorting it properly for some reason
regedare_ has joined #ruby
<nesoi>
fowl what am I doing wrong?
fearoffish has joined #ruby
eddie has joined #ruby
DarkFoxDK has joined #ruby
jlebrech has joined #ruby
trivol has joined #ruby
tatsuya_o has joined #ruby
tvw has joined #ruby
lampe2 has joined #ruby
banisterfiend has joined #ruby
<lampe2>
hey i created a gem with bundler and i added a new file into the projekt named sub folder of the lib folder. now i wanne require it into the app named rb in the lib folder but ruby says that he cant find it
<workmad3>
lampe2: gist your code please
<eddie_>
lampe2: did you mention the new file in gemspec ?
<lampe2>
eddie_, no must i?
<eddie_>
yes
<lampe2>
is there a easy way or must i do it manual ?
<luoluoluo>
hi there, how to print multi stars on the screen. for example: print '*' * 50 will print a line with 50 stars
<lampe2>
eddie_, if got this gem.files = `git ls-files`.split($\)
<eddie_>
you want to print from left to right
<eddie_>
?
<eddie_>
luoluolu: you want to print from left to right?
oposomme has joined #ruby
<luoluoluo>
eddie_: yes. I got it. I just made a mistake. thanks
arturaz has joined #ruby
fjfish has joined #ruby
<lampe2>
luoluoluo, just say after 10 stars /n for new line
<eddie_>
luoluoluo: ok
<oposomme>
hi I would like to know how do I mount a volume in ruby?
<luoluoluo>
lampe2: thanks. I already got it.
cbm has joined #ruby
<eddie_>
lampe2: try mentioning the straight away
<eddie_>
:)
<eddie_>
lampe2: Your gem?
nikhgupta1 has quit [#ruby]
darthdeus has joined #ruby
<lampe2>
eddie_, "gem.files = `git ls-files`.split($\)" i thought that this will add everything from the git repo what i add to git but it dont work :(
<eddie_>
lampe2: "gem.files = `git ls-files`.split($\)" . You checked what it gives
<eddie_>
?
<workmad3>
lampe2: can you give the require line that's failing please?
etehtsea has joined #ruby
<lampe2>
workmad3, require "lommongo/mdbConnect"
<lampe2>
eddie_, this gives me all files what i added with "git add ."
<Divinite>
Sigh... Why is my Ruby using the wrong encoding?
<Divinite>
It's using UTF-8
<eddie_>
lampe2: after step 4 your gem will be insdtalled properly
<lampe2>
thx eddie_
<eddie_>
Divinite: UTF-8 must be the default one
<Divinite>
But it says all my .gemspec's contain invalid characters...
<Divinite>
Why?
<luoluoluo>
eddie_: thanks. not what I want. I just want what "p '*' * 50" does.... I made a stupid mistake myself and figure it out right after I post the problem here.... Thanks for your kindness :D
regedarek has joined #ruby
<eddie_>
Divinite: gist of your gemspec
adman65 has joined #ruby
<eddie_>
lampe2: would like to see your gem. at rubygems.org
<eddie_>
Divinite: Mine is the same i have no issues yet
jenglish has joined #ruby
<lampe2>
eddie_, one day it will be up there but not today i just started the development. this will be a implementation of the LOM standard from the IEEE to save the meta data in a mongodb :)
Prezioso has joined #ruby
knirhs has joined #ruby
waxjar has joined #ruby
drewmacq has joined #ruby
<artm>
anyone familiar with guard? is there some best practice for combining multiple change events into one? like when I "Save All" in the editor, I'd like make to be called only once
sgupta has joined #ruby
Richmond has joined #ruby
drewmacq has quit [#ruby]
_class_ has joined #ruby
raluxgaza has joined #ruby
<maasha>
how are ruby arrays implemented? C arrays or list of lists sturcture?
<banisterfiend>
maasha: C arrays
<maasha>
banisterfiend: nice.
<eddie_>
lampe2: great. Share your github if you dont mind
<Divinite>
*sigh* Why is ruby so hard on iOS?
nikhil_ has joined #ruby
gavinmcnair has joined #ruby
araujo has joined #ruby
Foxandxss has joined #ruby
MrGando has joined #ruby
aibo has joined #ruby
frontendloader has joined #ruby
eldariof has joined #ruby
<shevy>
wat
<shevy>
not harder than ur mom
Rishi_ has joined #ruby
<Divinite>
shevy: Was that necessary?
<shevy>
for iOS sure
<banisterfiend>
Divinite: was it necessary to call him up on it? #ruby is not a nun's convent
<Divinite>
I know, but there was no need.
<Divinite>
"Ur mum" jokes only work when it's funny banisterfiend. Otherwise its just rubbish.
<banisterfiend>
Divinite: it was harmless all the same
<Mon_Ouie>
shevy: They changed their rules since then
<banisterfiend>
Divinite: he's not obliged to be funny, and he wasn't offensive, he was just silly at best. No reason to call him up on it
<Divinite>
I know, I know.
<Divinite>
I wasn't biting, just wondering.
<Divinite>
shevy: I'm jailbroken.
<shevy>
hmm
<dominikh>
all he contributes are bad and repeated urmom jokes and useless comments, so yeah, it starts to be pretty offensive
<shevy>
"The Agreement about Apple not accepting any coding language layer has been removed not too long ago. I guess we will have to wait a little to see complex language like Python and Ruby interpreter. Since LUA is a scripting language, it is easier to port it."
<shevy>
dominikh I like Divinite and his mom is actually nice, but you suck
<banisterfiend>
dominikh: he's our poppavic ;)
<shevy>
dominikh I wonder why you are obsessed with me though :>
<Divinite>
I have Ruby, Python, Perl, Lua...
<Divinite>
shevy: I'm a she, not a he.
<Divinite>
Or a shehe.
<shevy>
awww ok then indeed my joke was bad :(
<shevy>
sorry
<Divinite>
Don't worry shevy, I get that all the time on irc!
fuffi has joined #ruby
dbgster has joined #ruby
Indian has joined #ruby
FND has joined #ruby
r3dskade has joined #ruby
francisfish has joined #ruby
zeninfinity has joined #ruby
gianlucadv has joined #ruby
nikhgupta has joined #ruby
FND has quit [#ruby]
berserkr has joined #ruby
tk_ has joined #ruby
Prezioso has joined #ruby
sgupta has joined #ruby
catphish has joined #ruby
bl3k has joined #ruby
<catphish>
what's the class that makes a simple enum from a block?
banisterfiend has joined #ruby
batmanian has joined #ruby
<Divinite>
No idea.
schaerli has joined #ruby
<artm>
"scripting language" vs what?
DMKE has joined #ruby
<Divinite>
Nothing.
<Divinite>
Binary.
<catphish>
ah - Enumerator.new
<Divinite>
catphish: What?
<catphish>
it makes an enum instance from a block
falena has joined #ruby
<catphish>
eg: enum = Enumerator.new(&block); enum.each do |b|
etehtsea has joined #ruby
<banisterfiend>
catphish: why do u want to do that, out of interest
<catphish>
i can't remember now
<catphish>
i did it ages ago
<banisterfiend>
catphish: Enumerator.new is normally used for creating generators
<banisterfiend>
so it's a bit weird to see you iterate over it with #each IMO
Maxou56800 has joined #ruby
scalebyte has joined #ruby
KL-7_ has joined #ruby
MrGando has joined #ruby
<scalebyte>
I have a serialized ruby hash which has array of hashes inside. I want to sanitize the values of these hashes.. any possible solutions ?
raluxgaza has joined #ruby
bluenemo has joined #ruby
bluenemo has joined #ruby
<catphish>
banisterfiend: my use case is hard to explain, basically i have a method that iterates over incoming data live, so it needs to be passed what looks like a generator so that code can be processed as it arrives
sandstrom has joined #ruby
<catphish>
so my method calls .each, then the caller pushes data into it progressively
nikhil_ has joined #ruby
<banisterfiend>
catphish: ah ok
mcwise has joined #ruby
mengu has joined #ruby
Helius has joined #ruby
`brendan has joined #ruby
<`brendan>
morning folks
<artm>
good midday
sacarlson has joined #ruby
<artm>
internet English should evolve some longitude-agnostic greetings
tatsuya_o has joined #ruby
tatsuya_o has joined #ruby
headius has joined #ruby
<workmad3>
artm: you mean like 'hello' or 'hi'? :)
<roolo>
senthil: How did you solve that? Maybe the solution is similar
pzol has joined #ruby
<senthil>
roolo: For Fb I think it was the 'www' endpoint causing the trouble
TaTonka has joined #ruby
<senthil>
roolo: just a week back I was thinking about writing a wrapper for gcal
drake10 has joined #ruby
nikhgupta has joined #ruby
schovi has joined #ruby
ap0gee has joined #ruby
crankycoder has joined #ruby
rTypo has joined #ruby
BiHi has joined #ruby
lorandi has joined #ruby
KL-7 has joined #ruby
Drewch has joined #ruby
Progster has joined #ruby
moshee has joined #ruby
moshee has joined #ruby
bl3k has joined #ruby
evilgeenius has joined #ruby
kf8a has joined #ruby
ph^ has joined #ruby
geekbri has joined #ruby
bl3k_ has joined #ruby
ipoval has joined #ruby
ipoval has quit [#ruby]
fermion has joined #ruby
td123 has joined #ruby
nari has joined #ruby
robkinyon has quit [#ruby]
jonteru has joined #ruby
iocor has joined #ruby
Abhinav1 has joined #ruby
bl3k has joined #ruby
robkinyon has joined #ruby
Abhinav1 has joined #ruby
roolo has joined #ruby
dv310p3r has joined #ruby
dql has joined #ruby
fr0gprince_mac has joined #ruby
bluenemo has joined #ruby
headius has joined #ruby
astrostl has joined #ruby
<astrostl>
non-ruby/rails dev debugging a rails setup. if i strace a Rack process (passenger) and it's returning literally nothing while chewing up cpu resources, is it dead? is this a common thing? (xpost from #rubyonrails, don't know if this is straight ruby-related or not)
sbanwart has joined #ruby
jgarvey has joined #ruby
Sailias has joined #ruby
kidoz has joined #ruby
bglusman has joined #ruby
dql has joined #ruby
IrishGringo has joined #ruby
zeninfinity has joined #ruby
bluenemo_ has joined #ruby
cpruitt has joined #ruby
bbttxu has joined #ruby
bluenemo__ has joined #ruby
mdiedric has joined #ruby
jenglish has joined #ruby
bl3k_ has joined #ruby
a_a_g has quit [#ruby]
LBRapid has joined #ruby
jcromartie has joined #ruby
Jackneill has joined #ruby
chico has joined #ruby
jankud has joined #ruby
Guest53287 has joined #ruby
kpshek has joined #ruby
vandemar has joined #ruby
<jankud>
Hi, I am trying to find (without any luck so far) if there is a mechanism in Ruby similar to writev() and readv() i.e. read/write from vector of buffers
y3di has joined #ruby
zaydana has joined #ruby
maasha has joined #ruby
nikhil_ has joined #ruby
<maasha>
I am building a bitarray with 3 rows and 21 columns encoded in a 8 byte string. Every new row starts at every 7 bits. How to get the sum of each row using a single pass iteration of the byte string?
<y3di>
I know there are multiple resources for sending email with ruby, but does anyone have a suggestion of one, that they feel is the easiest to work with
phantasm66 has joined #ruby
PragCypher has joined #ruby
carlyle has joined #ruby
<canton7>
y3di, Pony is recommended, and I've personally found it works well
<maasha>
robkinyon: that is sort of what I am trying to do. I am just stuck where I want to count set bits 1 byte at a time instead of 1 bit at a time.
<robkinyon>
"count set bits" means what in English?
<maasha>
so for all rows, how many bits are set to 1.
bonhoeffer has joined #ruby
<robkinyon>
so, you have a bitvector (or bit array, whatever) and you want to know how many of the 63 bits (3 rows x 21 columns) are 1 vs. 0 ?
<bonhoeffer>
in a functional language like ruby -- objects still have persistent state -- how does this reconcile?
<bonhoeffer>
or is ruby a mix of imperative and functional?
<robkinyon>
bonhoeffer: ruby isn't a functional language, it's an OO language
<robkinyon>
functional languages are things like scala, haskell, lisp, etc
<maasha>
robkinyon: for each of the 3 rows, I want to know how many bits are set.
<roolo>
How clean do you think is this(for dealing with https)? http://git.io/NwwcZA
<bonhoeffer>
ok -- got it -- so how should i understand: Ruby supports multiple programming paradigms, including functional, object oriented, imperative and reflective.
<robkinyon>
ruby is much close to eiffel or smalltalk
astrostl has quit [#ruby]
<jcromartie>
"a functional language like Ruby…" O_o
<robkinyon>
bonhoeffer: because it does?
<bonhoeffer>
so ruby can do a functional paradigm -- but you are really working objects
<jcromartie>
I mean sure, as long as the only criteria is the ability to pass a closure
<jcromartie>
mutability is every-frickin-where
<bonhoeffer>
is the message receiver terminology unique to ruby?
<robkinyon>
maasha: loop over the bits and count ?
<maasha>
robkinyon: here is the code that does the sum of set bits for the entire bitarray: http://pastie.org/3641596
<robkinyon>
bonhoeffer: Umm … no. that's standard OO terminology
<robkinyon>
i believe it was coined that in the 1970's (1960's?) when Ada was created
<bonhoeffer>
sorry, i'm an engineer, not a CS guy, but i'm writing the contracting request for some software
<workmad3>
bonhoeffer: it's the original model for OO
<robkinyon>
bonhoeffer: write requirements, not implementation details
<bonhoeffer>
i code ruby by night, but i want the software to be developed to be flexible, and modular like a ruby app
<workmad3>
bonhoeffer: there's also the C++/java style that I call 'method calling OO'
<robkinyon>
make that a requiremen,t not the language
etehtsea has joined #ruby
<bonhoeffer>
robkinyon: i'm trying to do that -- but want to understand flexibility as a requirement
<robkinyon>
maasha: does that code work?
<bonhoeffer>
i'm not specifying the language
<workmad3>
bonhoeffer: define 'flexibility' ;)
<robkinyon>
bonhoeffer: What does flexibility mean to you?
<maasha>
robkinyon: it does actually
<robkinyon>
maasha: so . . . why are you trying to change code that actually works?
io_syl has joined #ruby
<bonhoeffer>
robkinyon: it means that we can make the code do what we want -- in this case traverse multiple scales to answer questions at various levels of fidelity
<bonhoeffer>
so we have multi-million lines of code now in big models that only a few people can run -- at one scale
<robkinyon>
bonhoeffer: in other words, you want the unix toolchain
<bonhoeffer>
they are run by hundreds of flat-text files -- in FORTRAN, etc
<maasha>
robkinyon: I can loop over one bit at a time, but that takes 8 times as long
badelat has joined #ruby
<workmad3>
maasha: so the code doesn't work because it fails your performance requirements
<robkinyon>
maasha: there are some things that are appropriate to write in C and other things that are appropriate to write in Ruby.
<maasha>
robkinyon: ah, that code bit makes a sum of the entirve bit array. I am trying to get it per row now.
<robkinyon>
maasha: bit-twiddling is appropriate to write in C
<bonhoeffer>
the flexibility i want is to maybe look at a few -on - few context -- then move to global objects
KL-7 has joined #ruby
<bonhoeffer>
it is desiging the application (or collection of objects) for a scientist/coder, not a mechanic
<bonhoeffer>
if that makes sense
<maasha>
workmad3: I want the evil speed. Not evil speed / 8 :o)
<robkinyon>
bonhoeffer: "flexibility" and "global objects" are archenemies. Think Joker and the Batman
<bonhoeffer>
please explain
Aristata has quit [#ruby]
<robkinyon>
well, you still have defined flexibility
<robkinyon>
haven't*
abstrakt has joined #ruby
<robkinyon>
not in a way that's actionable
<workmad3>
bonhoeffer: the larger the scope of something, the less amenable it is to change
<banisterfiend>
bonhoeffer: the langage you're developing in is fortran?
<bonhoeffer>
banisterfiend: trying to move away from fortran
<bonhoeffer>
i'm the young guy around . . . secretly coding ruby by night
<robkinyon>
bonhoeffer: you want the unix toolchain
<bonhoeffer>
and now tasked with spending a million bucks to develop the future tool we should use
<robkinyon>
go study why the unix toolchain is so successful and you will understand what flexibility means
<bonhoeffer>
robkinyon: any links?
<workmad3>
robkinyon: a.k.a. filters and pipes :)
<banisterfiend>
bonhoeffer: you should probably be using python if you're doing scientific computing
<workmad3>
(that's to bonhoeffer too btw)
<bonhoeffer>
you mean bash?
<robkinyon>
if you're confused, go read up on Netflix and the Chaos Monkey
<banisterfiend>
bonhoeffer: if u want to replace python that is
<robkinyon>
bonhoeffer: no … "the unix toolchain"
<banisterfiend>
replace fortran*
<bonhoeffer>
i think python might have a lot to leverage, SAGE, etc
<workmad3>
robkinyon: or are you meaning the tools that you tend to get in unix?
sirecote has joined #ruby
<robkinyon>
bonhoeffer: i just gave you two google-able terms. Go forth and cogitate.
<robkinyon>
workmad3: no. I said "the unix toolchain". it's a very specific term with a very specific meaning
<robkinyon>
"Each piece in the chain should do one thing, only one thing, and do it superlatively."
<robkinyon>
"Each piece in the chain should be able to read STDIN for input and write to STDOUT for output"
<robkinyon>
"Each piece must be hookable to each other piece"
<workmad3>
robkinyon: ah, the filters and pipes approach, that was what I originally thought :)
<bonhoeffer>
robkinyon: now i'm on to something
punkrawkR has joined #ruby
EvanR has joined #ruby
<robkinyon>
workmad3: it's much more than that. filters and pipes just covers "hookability"
BeLucid has joined #ruby
edogawaconan has joined #ruby
EvanR has joined #ruby
<robkinyon>
the key for bonhoeffer is "one and only one thing done superlatively"
akemrir has joined #ruby
<workmad3>
robkinyon: true... and I know what you mean, I'm just in a brain-dead state today when it comes to expressing things... I should probably shut up :)
A124 has joined #ruby
<robkinyon>
eh. that's why there's many of us - to work through exactly how to express something
<robkinyon>
tomorrow, i will be braindead and you will be on your game
dql has joined #ruby
theRoUS has joined #ruby
theRoUS has joined #ruby
jcromartie has joined #ruby
<EvanR>
its wednesday, its supposed to be the intersection of recovering from the weekend and winding in preparation for the weekend ! ;)
<EvanR>
winding down
oposomme has joined #ruby
<theRoUS>
meh
<theRoUS>
ruby 1.8.7.. is there any way to find out what action is the current handler for a specific signal *without* doing an 'x = Signal.trap(sig,'DEFAULT');Signal.trap(sig,x)' ?
immigrantX has joined #ruby
<bonhoeffer>
robkinyon: so does abstraction provide flexibility
<bonhoeffer>
we need to look over millions of scenarios and understand the flexbility and robustness of a collection of assets we invest in
<robkinyon>
bonhoeffer: the *right* abstraction provides flexibility
<theRoUS>
i want to know because SIGVTALRM can only have a trap set in a threaded environment; doing the trap/retrap throws an exception else
<robkinyon>
the wrong abstractions . . . well, those we don't talk about
<bonhoeffer>
ok -- I see what you are saying
kinderman has joined #ruby
<robkinyon>
bonhoeffer: often, too, we need multple layers of abstractions in order to get to the right point
<robkinyon>
so, we write abstractions on top of abstractions
DMKE has joined #ruby
<robkinyon>
and that's okay
<bonhoeffer>
so we are trying to write requirements that a contractor tells us their framework for solving this
<bonhoeffer>
but we don't want another monster that you have to develop a career in to run
snip_it has joined #ruby
bitrot has joined #ruby
<bonhoeffer>
and in my line of work -- onerous code means you focus on running on the model, not the insight you get from it
bl3k has joined #ruby
<robkinyon>
bonhoeffer: let's take this to /msg - this isn't ruby-related
<alem0lars>
I'm using YARD. I want to document my classes and methods using Textile. I tried both the command line argument --markup textile and including # @markup textile in the top of each file. However, it won't use Textile, but instead RDoc. How can I use Textile with YARD?
<alem0lars>
Is it possible to change the markup format for the documentation (YARD) in source files?
<abstrakt>
so I installed ruby 1.9.3-p0 from rvm, so I have the src folder, I just ran rdoc inside said folder because there don't appear to be any available downloads for the 1.9.3 documentation
<abstrakt>
the documentation is split in to core and stdlib
Maxou56800 has joined #ruby
<abstrakt>
after running rdoc in the 1.9.3-p0 source folder
<abstrakt>
will that have generated all the docs for stdlib as well
<abstrakt>
or will/does stdlib live in a different folder
<abstrakt>
my guess would be that it does generate docs for stdlib, I just wanna double check here
drknus has joined #ruby
alx- has joined #ruby
John_P has joined #ruby
d3vic3 has joined #ruby
tess has joined #ruby
mdw has joined #ruby
<shevy>
I guess the guys on #rvm may know, as far as I understood it though they keep everything that belongs to a specific version of ruby in the same directory specific to that version
wicchan_ has joined #ruby
adambeynon has joined #ruby
InBar has joined #ruby
andrewhl has joined #ruby
cjlicata has joined #ruby
bl3k_ has joined #ruby
wmoxam has joined #ruby
vandemar has joined #ruby
waxjar has joined #ruby
vipaca has joined #ruby
vipaca has joined #ruby
pu22l3r_ has joined #ruby
yoklov has joined #ruby
bbttxu_ has joined #ruby
shruggar1 has joined #ruby
rippa has joined #ruby
mickn has joined #ruby
havenn has joined #ruby
shtirlic has joined #ruby
igaiga has joined #ruby
CheeToS has joined #ruby
pu22l3r has joined #ruby
pdtpatr1ck has joined #ruby
AxonetBE has joined #ruby
<AxonetBE>
Is it a good idea to use a json for a radio button value?
pu22l3r has joined #ruby
rushed has joined #ruby
headius has joined #ruby
<fmcgeough>
is there a good writeup that someone can recommend on the available GUI Ruby frameworks for a straight app? (Windows, OS X, Linux). I'd like to bundle some things that I've written up for some support folks.
<shevy>
unless all you want to do is make simple hello world buttons
<fmcgeough>
the last time I wrote a desktop app I used Eclipse RCP… so anything is going to be an adventure.
adamkittelson has joined #ruby
Richmond has joined #ruby
_kinderman has joined #ruby
<shevy>
if you know ruby fairly well then all the toolkits will be quite similar anyway
nemesit has joined #ruby
ckrailo has joined #ruby
araujo has joined #ruby
araujo has joined #ruby
Shrink has joined #ruby
Jay_Levitt has joined #ruby
<dbgster>
does the Ruby hash have something similar to array#collect/map?
parsifal_ has joined #ruby
<parsifal_>
I realize this is the wrong place to ask this, but I can't figure this out and can't find it online. Does anyone know which markup syntax this is? http://cl.ly/3w0R152W2a2s461C2c0I
<shevy>
dbgster .map works on every member of an array. what would the .map version for a hash (with its key->value pairs) do?
flou has joined #ruby
iocor has joined #ruby
bl3k_ has joined #ruby
<shevy>
hmm
<dbgster>
it works on every member of an array, and returns a new array. so with a hash I guess it would work on the values of each key no?
flagg0204 has joined #ruby
<shevy>
why not the keys?
<shevy>
I am a bit confused right now though
devinus has joined #ruby
<shevy>
in my irb, hash seems to have a .map method
devinus has joined #ruby
<arturaz>
it works on |key, value|
<arturaz>
and returns an array
devinus has joined #ruby
<shevy>
ah yes
<robacarp>
parsifal_: to me it looks to be a markdown syntax with some custom addon
<dbgster>
if I have a module that has a class, I normally refer to it by: MYMODULE::MyClass.new
<dbgster>
is there a way to import a namespace?
bl3k has joined #ruby
<robkinyon>
import or alias?
<Mon_Ouie>
You can include modules and get access to their constants
<matti>
:>
Walenrod has quit ["Konversation terminated!"]
<dbgster>
so just: include MYMODULE
pdtpatr1ck has joined #ruby
oooPaul has joined #ruby
gen0cide_ has joined #ruby
oposomme has joined #ruby
wallerdev has joined #ruby
bl3k_ has joined #ruby
shruggar has joined #ruby
trivol_ has joined #ruby
williamcotton has joined #ruby
PragCypher has joined #ruby
zeninfinity has joined #ruby
alex__c2022 has joined #ruby
bricker88 has joined #ruby
a_a_g has joined #ruby
<Jay_Levitt>
Any Sublime Text 2 users? I just updated from 2189 to 2190 on Mac and now ST crashes at startup when the Ruby package is installed.. and the sublime forum is down :/
bl3k has joined #ruby
hydrozen has joined #ruby
rTypo has joined #ruby
apucacao has joined #ruby
ed_hz_ has joined #ruby
<Beakr>
Ruby package? Doesn't Ruby come built-in?
darthdeus has joined #ruby
<Beakr>
Jay_Levitt: I use Vim but I'm pretty sure ST should start normally if Ruby comes built-in like it did when I got it. You might want to find a ST channel if there is one more than the Ruby channel.
mafolz has joined #ruby
<Jay_Levitt>
Beakr: Nah, looked for a channel and no luck.. actually seems to be a package that updated, not ST itself - I just downrevved to 2189 and it still happens
<Beakr>
Jay_Levitt: Could be a bug with the package update itself.
<Jay_Levitt>
Beakr: Also true
<Beakr>
Jay_Levitt: If you can uninstall the package maybe it would work.
antonishen has joined #ruby
<Jay_Levitt>
Beakr: Yeah, unfortunately I just pulled the two packages that Package Control mentioned updating and it's still crashing, might be something else tho
bl3k_ has joined #ruby
jgrevich has joined #ruby
<Beakr>
Jay_Levitt: If it doesn't get patched or uninstalled you could consider reporting it.
shyam has joined #ruby
<Jay_Levitt>
Beakr: Right - the hard part is figuring out what's crashing!
<Jay_Levitt>
Beakr: Never have I been so happy that ST starts up quickly, tho :)
<zandt>
you should try emailing from the website.... not sure who handles that, but I noticed that, too. (it's been dead a while)
trivol_ has joined #ruby
PragCypher has joined #ruby
<cpasmoi>
well I'm new to ruby, have to practice it in order to get a job but ok, i'll mail the webmaster
td123 has joined #ruby
araujo has joined #ruby
araujo has joined #ruby
wicchan_ has joined #ruby
pastjean has joined #ruby
fr0gprince_mac has joined #ruby
williamcotton_ has joined #ruby
jcromartie has joined #ruby
Araxia has joined #ruby
<dbgster>
so when I do: attr_accessor :some_att
blacktulip has joined #ruby
<dbgster>
if I want this to be a hash, can I add: def some_att; self.some_att ||= []; end
y3di has joined #ruby
<dbgster>
is that correct?
ballpointcarrot has joined #ruby
<workmad3>
dbgster: no... that would be infinite recursion
<workmad3>
dbgster: also, [] is an array literal, not a hash literal
<dbgster>
yes sorry {}
<workmad3>
dbgster: doesn't stop the infinite recursion ;)
<dbgster>
hehe…yes I was hoping you were going to correct me
<dbgster>
removing the self?
<workmad3>
dbgster: if I just correct you, you don't learn anything ;)
<workmad3>
dbgster: especially in a language like ruby, where you can just open irb and play with code
<dbgster>
uhm…how's that?
<dbgster>
k
ghanima has joined #ruby
pu22l3r has joined #ruby
<workmad3>
dbgster: I'm a believer that an answer you work out for yourself is a better learning experience than one handed to you
iocor has joined #ruby
<dbgster>
well I can just create a attr_writer
<shevy>
dbgster but not when you want self.foo
<dbgster>
then I need @foo
apeiros_ has joined #ruby
<shevy>
but really, the attr* aren't doing anything magical
<shevy>
you can write ruby code without using them
<rippa>
or you can write them yourself
<cpasmoi>
Is there a way with Time Class to convert a time format "2012-01-12" to "12/Jan/2012" (the slash separator can be handled with regexp I guess) ? I only see the contrary (Time.utc (2012,"jan",12) => 2012-01-12
ascarter has joined #ruby
cloke has joined #ruby
ed_hz_ has joined #ruby
<rippa>
cpasmoi: Time#strftime
luxurymode has joined #ruby
<cpasmoi>
thanks ! I'll look forward
adamkittelson has joined #ruby
MrGando has joined #ruby
madhatter has joined #ruby
deryl has joined #ruby
kpshek has joined #ruby
asobrasil has joined #ruby
ringotwo has joined #ruby
frontendloader has joined #ruby
SeanLazer has joined #ruby
CannedCorn has joined #ruby
carlyle has joined #ruby
<SeanLazer>
hey guys, i seem to remember that there's a way to have an instance of a class return something other than itself, like if you call @instance_of_class it would actually give you @intstance_of_class.to_s
<SeanLazer>
did i dream that up or is that a thing?
<apeiros_>
you have been dreaming
carlyle has joined #ruby
<apeiros_>
@ivar is an instance variable, as a variable, all it can ever do is reference an object.
mmokrysz has joined #ruby
<apeiros_>
so it will always evaluate to the object that has last been assigned to it
<SeanLazer>
alright maybe i need help with an implementation strategy
sungji has joined #ruby
<SeanLazer>
I have a simple settings class, similar to Settingsclass, but checks three sources (database, yml file, env vars) for the setting
<SeanLazer>
i want to be able to call something like Settings.api_key and get the value of api_key
<SeanLazer>
but also be able to call Settings.api_key.source and find out what the source is
<SeanLazer>
(settings is a singleton)
<cpasmoi>
thank you rippa that's exactly what I was looking for :)
carlyle has joined #ruby
ringotwo has joined #ruby
<apeiros_>
SeanLazer: um, note that what you now just asked has nothing to do with your initial question. ivars and methods are largely unrelated (and Settings.api_key is a method)
<SeanLazer>
oops, when i said similar to Settingsclass i meant similar to Settingslogic
mrsolo_ has joined #ruby
havenn has joined #ruby
<apeiros_>
if you want it to be that way, api_key must return an object that responds to .source, what's your problem with doing that?
<rippa>
Settings.source.api_key
<rippa>
would work for that porpoise without trickery
<SeanLazer>
apeiros_: i know, i've jumbled this up in my head. i just used @ivar to represent something which had been set to an instance of a class. also in my first implementation i had .api_key returning an object
lkba has joined #ruby
mmokrysz has quit [#ruby]
<apeiros_>
SeanLazer: you are being fuzzy - every value in ruby is an object.
<apeiros_>
you can't return anything *but* an object
<SeanLazer>
apeiros_: so i guess my question is this, how do i structure it so that Settings.api_key returns a string but Settings.api_key.source is also available? just dynamically add those methods to the string itself?
<SeanLazer>
and yes i know i'm explaining this really poorly, imagine that i was a guy who understood ruby fairly well but hadn't eaten lunch yet ;)
AxonetBE has joined #ruby
<apeiros_>
SeanLazer: again, everything is an object, a string is an object too
<apeiros_>
you can define additional methods on any object just fine
<SeanLazer>
apeiros_: so that would be your approach if i wanted that interface?
<apeiros_>
SeanLazer: *my* approach would probably be what rippa suggested
<apeiros_>
but if you want *your* approach, then just extend the string you return with all the necessary methods & data
<apeiros_>
see Object#extend, or alternatively, def obj.some_meth; …; end
stephenjudkins has joined #ruby
<apeiros_>
also Object#define_singleton_method
<SeanLazer>
apeiros_: i'm designing around a specific interface that i had in mind based on how i think other devs might use this code, i think it's more clear this way but maybe i'm wrong
<SeanLazer>
i'll check out the documentation on that stuff, thanks
maasha has joined #ruby
kinderman has joined #ruby
mikepack has joined #ruby
<phantasm66>
is there a class or core method that can tell me if a another process has a file "open"?
<maasha>
How do convert a ruby array, passed to a C function as VALUE rb_ary, to a C array?
wallerdev has joined #ruby
<apeiros_>
maasha: read README.EXT
<apeiros_>
iirc it's a macro
<maasha>
apeiros_: yeah, I am staring at this but cant quite locate it:http://www.eqqon.com/index.php/Ruby/Ruby_V1.9_C_Extension
<apeiros_>
phantasm66: I don't think so. there might be gems that do that. probably not in a platform-agnostic way, though.
<apeiros_>
maasha: that's not README.EXT.
<maasha>
apeiros_: nope, but thats what I have been reading :o)
<delinquentme>
what does a & do when attached to an argument?
<delinquentme>
def merge_sort(&predicate) < example
dross_ has joined #ruby
nfluxx has joined #ruby
<rippa>
delinquentme: passes argument as bock
<rippa>
*block
<apeiros_>
and calls .to_proc on it if necessary
pdtpatr1ck has joined #ruby
kf8a has joined #ruby
cloke has joined #ruby
iocor has joined #ruby
__Grabarz__ has joined #ruby
<norm>
can i specify a gem source for a dependency in a .gemspec file?
seivan has joined #ruby
cbuxton has joined #ruby
badabim has joined #ruby
__Grabarz__ has quit [#ruby]
havenn has joined #ruby
Nss has joined #ruby
<apeiros_>
norm: afaik, no
<apeiros_>
it wouldn't make sense anyway
sako has joined #ruby
francisfish has joined #ruby
<sako>
hey guys, has anyone figured out the gcc issues with ruby and osx lion yet?
<apeiros_>
sako: I think you can just install the gcc from kenneth reitz on github
stringoO has joined #ruby
<sako>
apeiros_: i see, i was reading kenneth's blog and was under the assumption that xcode command line tools does exactly what his packages did?
<sako>
already have xcode command line tools installed
<apeiros_>
ah, right, apple now provides gcc separately
<apeiros_>
then I'd guess all you have to do is use the right gcc…
davidcelis has joined #ruby
<norm>
apeiros_: i'm still differentiating gemspecs and gemfiles. i'm developing a home-grown gem that depends on another home-grown gem. in production, these come from an internal gem server. for development, should i just manually install the dependencies?
<apeiros_>
norm: configure your rubygems for your custom source, not the gem
<apeiros_>
alternatively, specify it in the gemfile
flou has quit ["Leaving..."]
stkowski has joined #ruby
c0rn has joined #ruby
schovi has joined #ruby
n1x has joined #ruby
dross has joined #ruby
mikepack has joined #ruby
cbuxton has joined #ruby
Indian has joined #ruby
cjlicata has joined #ruby
csprite has joined #ruby
snip_it_ has joined #ruby
Divinite has joined #ruby
csprite has joined #ruby
ringotwo has joined #ruby
advorak has joined #ruby
cbuxton has joined #ruby
ringotwo has joined #ruby
kpshek has joined #ruby
alup_ has joined #ruby
HektoR has joined #ruby
waxjar has joined #ruby
<HektoR>
hello guys... is there any ruby full text search engine like Lucene for java ?
<apeiros_>
HektoR: afaik, there's ruby bindings for lucene
<apeiros_>
and of course, with jruby you can use whatever exists for java
pdtpatr1ck_ has joined #ruby
<apeiros_>
I think solr was the name of the ruby binding
<apeiros_>
ah, no, it was ferret. but solr is relevant too in this context.
<HektoR>
apeiros_: is jruby effecient ?
shell0x_ has joined #ruby
<apeiros_>
define efficient
cameron_ has joined #ruby
mcwise has joined #ruby
<apeiros_>
it runs on the jvm and is well suited for server tasks
Gekz has joined #ruby
Gekz has joined #ruby
CannedCorn has joined #ruby
robkinyon has joined #ruby
ByteCrunch has joined #ruby
badelat has joined #ruby
litejk has joined #ruby
litejk has quit ["696 programming language || ruby-lang.org || Paste >3 lines of text in http://pastie.org || Rails is in #rubyonrails"]
choffstein has joined #ruby
bhunt has joined #ruby
ByteCrunch has joined #ruby
Nisstyre has joined #ruby
thecreators has joined #ruby
sacarlson has joined #ruby
greenarrow has joined #ruby
gianlucadv has joined #ruby
Gekz has joined #ruby
sandstrom has joined #ruby
sandstrom has joined #ruby
interopcop has joined #ruby
pdtpatr1ck has joined #ruby
<interopcop>
can anyone suggest an Array funciton for removing an item from a sorted array (which is actually a set). here's my code: https://gist.github.com/2150809
<interopcop>
I have assembled an Array of SoftwareRelease id's. I need to trim off id's which refer to SoftwareReleases which are before current
lorandi has joined #ruby
<yxhuvud>
interopcop: I suppose you are aware that there are already a set implementation you could use? require 'set'
codespectator has joined #ruby
stefanp has joined #ruby
stefanp has joined #ruby
stefanp has joined #ruby
<interopcop>
yxhuvud: so essentially if I make the Array a set, then I can still sort it and group it as I do, but at the end I can just return it as an array if the client expects an array in the interface?
<maasha>
I want to define a slice method that takes arrays/ranges as arguments like slice([1], [2 ... 5]), but the range is not turned into an array?
<apeiros_>
nate_h: wow, why does it not print the actual error message but only the backtrace?
<apeiros_>
that's like superstupid and evil at the same time…
<nate_h>
well err: no such file to load -- rspec
<nate_h>
thats the error
<nate_h>
i figured?
<nate_h>
i ran my puppet in debug/trace mode to see that other stuff
<apeiros_>
aaay, they… seriously write the backtrace first and THEN the error message?
<apeiros_>
how stupid is that…
<apeiros_>
thanks for pointing it out, I didn't see it
<nate_h>
ya that's just the format they use I guess
<nate_h>
anyways, this function works totally fine in another puppet server
<nate_h>
diff os
<nate_h>
so it has to be some kind of ruby pathing issue
<apeiros_>
nate_h: please make a paste of the output of `gem env` and check, whether rspec is listed in `gem list`
CannedCorn has joined #ruby
bwlang_ has joined #ruby
<apeiros_>
nate_h: or permissions issue…
CannedCorn has joined #ruby
tbrock has joined #ruby
<nate_h>
apeiros_, if it were a permission issue what would I check? THis is running as root
otters has joined #ruby
<apeiros_>
well if you run as root, permissions issues are unlikely I'd say… what you'd check: whether you have read rights on the rspec.rb file in the lib dir of the rspec gem
<swarley>
i see String#tr in the rdoc, (assuming it behaves like perl's tr/A-Z/Z-A/) but I do not seem to have the method available to use. Trying in pry using ruby 1.9.3
<apeiros_>
swarley: how did you try?
<swarley>
i tried show-doc String.tr
<burgestrand>
swarley: show-doc String#tr
<apeiros_>
I mean how did you try to *use* it
<epochwolf>
does ruby use the quicksort algorithm for Enumerable#sort_by ?
<swarley>
ah
<swarley>
i feel silly now
<apeiros_>
epochwolf: I think so
<epochwolf>
fuck fuck fuck fuck
<swarley>
it seems to produce different results
<swarley>
at first it was a no method error, i thought
<apeiros_>
epochwolf: why's that fuckfuckfuck?
<TTilus>
epochwolf: come down...
<apeiros_>
even quadruplefuck
<burgestrand>
epochwolf: yes it does
<epochwolf>
apeiros_: quicksort isn't stable
<burgestrand>
epochwolf: just attach the index before sorting
cespare has joined #ruby
<apeiros_>
epochwolf: ah
<apeiros_>
yeah, sort makes no promises about stability
<apeiros_>
neither does sort_by
<epochwolf>
burgestrand: yeah, I'll have to sort_by with a hash.
<epochwolf>
errr array
<apeiros_>
so even if it was stable, you should not rely on it
<epochwolf>
apeiros_: this application is locked on 1.8.6 and will be until the end of time.
<epochwolf>
apeiros_: forms.sort_by(&:name).sort_by(&:sequence) should be form.sort_by{|f| [f.sequence, f.name]}
<burgestrand>
y3di: post your error
<y3di>
NoMethodError at / undefined method `slim' for <app>
<apeiros_>
epochwolf: um, no
<epochwolf>
no?
<apeiros_>
that's different, even with stable sort
<burgestrand>
y3di: *shrugs* did you try requiring slim before sinatra?
schovi has joined #ruby
<burgestrand>
I mean, hopefully makes no difference, but it might
<epochwolf>
apeiros_: how so?
<apeiros_>
["a",1], ["b",0]
<y3di>
ill tyr that
<apeiros_>
with sort_by chained, that'll be b first, then a
<apeiros_>
ah
<apeiros_>
oh, you inverted… wait
<apeiros_>
but still, it's not the same
<apeiros_>
I just need to adapt my example
<epochwolf>
apeiros_: I need my forms sorted by sequence, and then alpha by name if the sequence is the same.
<apeiros_>
well, why don't you just use the latter form anyway?
<epochwolf>
apeiros_: I am
<apeiros_>
no, you're right, with stable sort it's the same
<apeiros_>
*it'd be
<y3di>
burgestrand: yea didn't help
<epochwolf>
apeiros_: see, I'm not an idiot. :)
<apeiros_>
epochwolf: there was a 95% chance…
<epochwolf>
that I was?
<apeiros_>
with a tendency of becoming a 98% chance…
<apeiros_>
yes :)
<epochwolf>
apeiros_: thank you :D
<apeiros_>
oh, that's related to general demographics and probability ;-p
<y3di>
apeiros_ & epochwolf: do you guys have any suggestions for me?
jangell has joined #ruby
Gesh has joined #ruby
<apeiros_>
y3di: given that I use neither slim nor sinatra - no
<epochwolf>
y3di: non-sarcastic ones only I assume?
vikingly has joined #ruby
<y3di>
epochwolf: yea =/
<epochwolf>
rather, I only have sarcastic ones
<jangell>
I'm trying to find a gem for forking workers with a pool of jobs….and I need some way for them to send data back to the parent…any tips?
<y3di>
epochwolf: actually go for it anyways
<epochwolf>
y3di: use rails :P
maletor has joined #ruby
}0 has joined #ruby
<Spaceghostc2c>
It's easy to refactor after rails, just replace it with padrino on jruby.
<y3di>
epochwolf: bah, i think i'll stick with python. If only I didn't have to TA this webware class that uses ruby =/
<epochwolf>
Spaceghostc2c: you are evil. I like you.
tatsuya_o has joined #ruby
<Spaceghostc2c>
:D
<vikingly>
Hi! I have some methods that return a value hash of the same format. Is there a best practice better than just returning a hash? Ex. of hash returned from methods: { :quantity => 0, :price_per => 0, :subtotal => 0, :service_fee => 0, :trans_fee => 0, :total => 0, :currency => 'USD' }
<Spaceghostc2c>
y3di: Yeah, sometimes having only one way to do things is fun.
<Spaceghostc2c>
Notreally, but I'm trying ot be nice here.
<epochwolf>
vikingly: use a class?
shtirli__ has joined #ruby
<vikingly>
epochwolf: I am considering that. Should I just use a plain class or is there a best practice on an API in the class (e.g operators implemented)?
<y3di>
Spaceghostc2c: i use clojure and php too =p
<epochwolf>
vikingly: there is an OpenStruct in the standard library if you just want to wrap a hash
<Spaceghostc2c>
y3di: You poor mortal.
<y3di>
Spaceghostc2c: xD
* Spaceghostc2c
is a ginger. :(
<epochwolf>
y3di: you are dead to me.
<y3di>
Spaceghostc2c: used php*
* epochwolf
makes out with Spaceghostc2c instantly.
<apeiros_>
any-key: yes, now take a really close look at that table
<apeiros_>
it says exactly what I just said.
<any-key>
aghhh
<any-key>
thanks...I should stop skimming things
<any-key>
>.<
<apeiros_>
great, you stopped fighting the evidence :-p
<any-key>
I looked into it before asking here, saw that first 8 and was like "wtf"
<apeiros_>
but yes, of course dec 8 is hex 8 :-p
<arphen>
can d=file.open("/etc/.vimrc") ; d.puts("blabla");d.close();d=file.open("/etc/.vimrc/");s=d.gets() ever fail?
<arphen>
i.e: writing something to a file and immediately reading it?
<arphen>
because i think that's happening to me
<apeiros_>
arphen: a) use block form of open
<apeiros_>
b) really, if you paste code, CASING MATTERS, don't short-cut it, you just confuse everybody
<arphen>
i just typed it out...
<arphen>
does the block form do anything else than "close"?
<apeiros_>
it ensures the close, which you don't
<arphen>
you mean in case of an exception?
<apeiros_>
for example
<arphen>
meh... my basic question stands. if i call file.close() and it succeeds, will the write be carried out before any sequential reads?
<apeiros_>
it should
<apeiros_>
ruby builds on the OS' API, so it really depends on that
<arphen>
:(
<arphen>
i hate these bugs
<apeiros_>
I only hate bugs I don't get paid to fix :-p
<shadoi>
arphen: you're still at the mercy of the OS filesystem buffering, etc.
<Spaceghostc2c>
apeiros_: I actually enjoyed that working with unix books.
y3di has joined #ruby
<Spaceghostc2c>
s/s//
adman65 has joined #ruby
<arphen>
yeah you may go ahead and laugh at me now shadoi
<arphen>
:D
<arphen>
but i think i found the course
<arphen>
s/course/cause
<shadoi>
arphen: I'm not laughing, but I did tell you so. ;)
<arphen>
s_s/course/cause_s/course/cause/_
<apeiros_>
of course you found the cursed cause
jgrevich has joined #ruby
<arphen>
i was just using old data instead of properly refreshing it
cbuxton has joined #ruby
kgraham has quit [#ruby]
<arphen>
i am pleased by the amount of stuff im learning right now
fowl has joined #ruby
<arphen>
this internship was a splendid idea
<arphen>
i can work whenever i want, wherever i want
<shadoi>
arphen: maybe this is the pain your manager was trying to get you to learn by forcing you to use files. Or maybe he's just dumb. :)
<arphen>
i have my own project, lots of time and i already got paid
cbuxton has joined #ruby
<arphen>
plus it's the last missing piece for my degree :)
<arphen>
next week i'll be looking into jQuery
<arphen>
i enjoy web dev since there is no such thing as "overly paranoid" in web dev
jgrevich has joined #ruby
sjhuang has joined #ruby
AxonetBE has joined #ruby
<Spaceghostc2c>
paranoid in what fashion?
<Spaceghostc2c>
This sounds like a very slick slope.
<any-key>
as long as you're paranoid in the right way it's good
jgrevich has joined #ruby
<arphen>
it's not paranoid if they are out there
<arphen>
just kidding, i mean the whole security stuff, man in the middle etc, having to think before you store passwords and how you store passwords
<arphen>
i'm doing most stuff by hand so i'm implementing challenge response salt codes etc
<any-key>
doing stuff by hand can be dangerous :P
<arphen>
i also know that... im not re implementing sha or rsa
nikhgupta has joined #ruby
<any-key>
haha
havenn has joined #ruby
<any-key>
is there some cool syntax for a single line function definition?
<any-key>
I have a bunch of lines that just do @serial.write(asdfasdf)
<any-key>
and I know about semicolons :P
<apeiros_>
no. there's just the ordinary "use ; instead of newline"
<apeiros_>
or "use unambiguous syntax"
<apeiros_>
e.g. `def foo() "bar" end` is valid
<any-key>
maybe there's a way cooler way of doing this: I have a bunch of constants that define opcodes, and the class I'm writing has a function that sends each opcode
Ontolog_ has joined #ruby
<any-key>
so it gets kind of tedious, but I want the end result to be class.opcode rather than something like class.mode(opcode)
axl__ has joined #ruby
dnyy has joined #ruby
<any-key>
well, nah, I'll just use that second method for it
<apeiros_>
you can use metaprogramming to let ruby create your methods for you
<arphen>
it is higher level wizardry
<any-key>
yeah...I suppose I could do that
Russell^^_ has joined #ruby
<any-key>
that involves a metaclass, doesn't it?
<any-key>
I never understood those
<TTilus>
doesnt have to
<any-key>
what would be the cool way of going about this?
<any-key>
I have an array of opcodes, and I want to iterate through and add a method for each based on a proc
<vikingly>
I am using a class to return values (Ex. https://gist.github.com/9bfd99af5ad76f81c0d5 ). How do I redefine the += operator on this class? For A+=B I'd like += to add attributes in all attributes in AMOUNT_CALC_ATTRIBUTES from B to A, and fail if an attribute is not defined in A or B.
<TTilus>
share your non-cool way so we'll what you are up to
<TTilus>
any-key: "based on a proc"?
<any-key>
TTilus: I just have a bunch of constants, like "START" which each have a function in the class such as Roomba::start
<TTilus>
any-key: def method_missing(method); Roomba.send method; end
<TTilus>
any-key: ?
<epochwolf>
vikingly: you recreated OpenStruct?
<any-key>
method missing is a bit slow, though
<TTilus>
any-key: why not just have the methods?
<any-key>
TTilus: there's quite a few opcodes
<vikingly>
epochwolf: I'd like to add a += operator and I'd like to fail if all attributes in AMOUNT_CALC_ATTRIBUTES are not defined, which is why I choose class instead.
<any-key>
TTilus: define_method should do the trick
<epochwolf>
vikingly: that work
<epochwolf>
s
<TTilus>
any-key: but you'll have the opcodes as methods, it really doesnt make any difference if they are hardcoded or define_method-generater
<Mon_Ouie>
There's no += operator in Ruby. a += b expands to a = a + b
<shadoi>
vikingly: assignment operators are not user-definable unfortunately.
<Mon_Ouie>
So you just have to define the + method
<TTilus>
any-key: or is there something you arent stating
<any-key>
TTilus: I'm too lazy to type out all of these methods, it'll make my code look cleaner
<TTilus>
any-key: good argument
<TTilus>
any-key: just all_opcodes.each { |opcode| define_method(opcode) { ...whatever you do... } }
<any-key>
yeah, that's the idea
<vikingly>
shadoi: Mon_Quie: epochwolf: any suggestions on best practices to defining += equivalent semantics between two objects?
<TTilus>
vikingly: define +
<vikingly>
TTilus: the idea was to avoid object creation. Should I not worry about that?
<shadoi>
vikingly: I usually just define +, and << for set/array-like things.
<TTilus>
vikingly: i dont know if your objects are particularily heavy to create, u tell me
jgrevich has joined #ruby
<Mon_Ouie>
You can create another method like merge or << if it's a problem
io_syl has joined #ruby
<vikingly>
TTilus: I usually error on the side of allocating very few temporary objects as I don't want to be too reliant on the garbage collector. In this case I'll sum over an array of objects. However, the array will usually be less than 100 in size.
<TTilus>
how would one be "too reliant on the gc"?
ph^ has joined #ruby
<TTilus>
you mean "need to gc too much"?
<TTilus>
or do you expect gc to fail somehow?
<vikingly>
yes, need to gc more objects than strictly necessary.
<TTilus>
just profile your memory usage and see if the solution you use "needs gc more objects than strictly necessary"
<TTilus>
whatever that is
jgrevich has joined #ruby
<RubyPanther>
vikingly: as said += doesn't mean that in Ruby, but << is usually the equiv. mutator
<vikingly>
RubyPanther: TTilus: I am programming up two solutions now, and I'll test them both up. '<<' with the equiv semantics to +=, and overloading of the '+' operator.
mikepack has joined #ruby
mikepack_ has joined #ruby
mikepac__ has joined #ruby
mikepack has joined #ruby
punkrawkR has joined #ruby
jgrevich has joined #ruby
jcromartie has joined #ruby
emmanuelux has joined #ruby
luke--_ has joined #ruby
<CannedCorn>
what is the best way to have a default and a minimum value for an opt
<CannedCorn>
@var = opt.fetch(:var, default)
<CannedCorn>
@var = min if @var < min?
jgrevich has joined #ruby
<CannedCorn>
or is there a cleaner way to write that code
Tearan has joined #ruby
<apeiros_>
looks fine
igaiga has joined #ruby
<apeiros_>
if you want to do an arguments check on opt, you can use delete with a block instead of fetch
<apeiros_>
but don't forget to dup opt before you start deleting stuff (mutating arguments is rude)
<CannedCorn>
apeiros_: could you explain a bit more
<CannedCorn>
why is that rude?
<apeiros_>
because a user doesn't expect a method to modify something you pass to it
<apeiros_>
a method should generally only modify the receiver
<apeiros_>
(i.e., self)
<CannedCorn>
got it
<CannedCorn>
hrm so why not simply pass a block to fetch?
luckyruby has joined #ruby
<apeiros_>
as for args checking, it'd go like: def foo(opts={}); opts=opts.dup; some_opt = opts.delete(:some_opt) { default }; raise "Invalid options: #{opts.keys.inspect}" unless opts.empty? …
landfall has joined #ruby
<apeiros_>
because if you delete the option, you can check in the end whether there's unknown keys left, as seen above
<CannedCorn>
yep
zakwilson has joined #ruby
<CannedCorn>
ah because and passes in the key
<apeiros_>
alternatively you can of course just do: unknown_keys = opts.keys-known_keys; raise … unless unknown_keys.empty?
<shadoi>
I usually don't modify opts at all, I do something like: opts.each {|k,v| self.send("#{k}=", v) if valid_opts.include?(k)
<shadoi>
and then for assignment defaults: @opt1 ||= "default"
<shadoi>
missed my last } on that iterator
<CannedCorn>
oh wait, but i want to implement a minimum if fetch/delete do return something
blacktulip has joined #ruby
<apeiros_>
CannedCorn: that part doesn't change ;-)
<davidcelis>
CannedCorn: back when I had a radio show in college, I had a listener that would come into chat as "tastytastycorn" and make trollish phone calls
<CannedCorn>
right, but there is no way to do it on one line
<CannedCorn>
that wasn't me davidcelis
<CannedCorn>
sorry
<davidcelis>
I know
swarley has joined #ruby
<davidcelis>
I just wanted to tell you that story
<CannedCorn>
haha or was it?
<davidcelis>
It wasn't
mikeg has joined #ruby
norex has joined #ruby
<CannedCorn>
ok ok
<davidcelis>
lol
<CannedCorn>
it just sems like i should be able to do some fancy logic
<CannedCorn>
in one line that says
<CannedCorn>
try to get the value of this key, default is this, min is this
<CannedCorn>
or maybe the way i wrote it was optimal
<CannedCorn>
just seemed janky
<vikingly>
TTilus: RubyPanther: shadoi: Thank you for the pointers.
<RubyPanther>
vikingly: your benchmark is badly broken and doesn't tell you anything
<RubyPanther>
in one case you throw away the result, and in the other, you concatenate the results
NotAzure has joined #ruby
<RubyPanther>
well, or whatever happens to it
<RubyPanther>
and << isn't supposed to just call foo= it is normally supposed to be able to change the object data directly, where that is possible
<vikingly>
RubyPanther: But I don't know how to make << change object data directly
<swarley>
what are you trying to do
<swarley>
okay so
<swarley>
why
<swarley>
attr_accessor *AMOUNT_CALC_ATTRIBUTES
<swarley>
what am i missing there
<swarley>
shouldnt that be a symbol?
<apeiros_>
no
<swarley>
oh
<swarley>
i see
<swarley>
i feel stupid
<apeiros_>
AMOUNT_CALC_ATTRIBUTES should be an array of symbols (or strings)
<swarley>
yeah
<swarley>
i saw it after i said it
}0 has joined #ruby
darthdeus has joined #ruby
<apeiros_>
also, variables vs. objects
<apeiros_>
a symbol is an object, a constant is a variable
<vikingly>
swarley: I am returning the same set of numbers from multiple methods. I am defining a class that holds those return values and overloads the + operator.
<apeiros_>
(even if it sounds contradicting)
<swarley>
i see
MasterIdler_ has joined #ruby
<apeiros_>
iow, everything you can assign to is a variable. you can't assign to a symbol. :foo = 1 # not possible
PragCypher has joined #ruby
kreiggers has joined #ruby
<swarley>
no
<vikingly>
also, + will fail if one or more of the AMOUNT_CALC_ATTRIBUTES are not defined. I liek failing early.
<swarley>
apeiros_, im not confused about that
<swarley>
i just over looked the contents of the constant
nari has joined #ruby
landfall has joined #ruby
MasterIdler_ has joined #ruby
<vikingly>
RubyPanther: another flaw of my benchmark is that it does not really measure the cost of gc as it is a short-running program, and it does not measure peak memory usage.
pu22l3r has joined #ruby
<arphen>
i still couldnt figure out
<arphen>
how do i view a file's size on the command line in human readable format?
<vikingly>
RubyPanther: thanks. That is the same result I got in my improved gist. With strings '+' is faster in this particular benchmark, and '<<' is faster with numbers.
johnduhart has joined #ruby
<RubyPanther>
vikingly: In the one I gave with << used correctly (on arrays) it should be quite a bit faster than +
<mikeliss>
OK, so just using double paren? Wait, I'm not sure I follow.
<mikeliss>
grr, and by parens, I mean quotes.
<mikeliss>
This is what I currently have: text.gsub(from.to_s, to.to_s)
<RangerMauve>
What he's doing there is specifying a string instead of a regex, and it looks for that combination of characters, and subs it with the second argument