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/
startling has quit [#ruby]
<shevy>
make_loaderror.rb:1:in `require': no such file to load -- hi (LoadError)
<shevy>
from make_loaderror.rb:1
<shevy>
if I do:
<shevy>
require 'hi'
<shevy>
davidpk, so something is odd with your code if it does not give you more information
<shevy>
perhaps something is doing a begin/rescue and giving you that changed error message?
burns180 has joined #ruby
<davidpk>
I can require the main file directly, that works
<kandinski>
I am trying to zip two arrays into a hash this way: my_hash = Hash(a.zip(b)), but get this error: 23:04 < dato> org babel++
<kandinski>
23:05 < dato> reproducible research++
<kandinski>
damn, sorry
<kandinski>
wrong paste, this error: NoMethodError: undefined method `Hash' for main:Object
<kandinski>
I get it both in irb and in my rails code. What am I doing wrong?
KindOne has quit [#ruby]
facefox has joined #ruby
mikepack has joined #ruby
burns180_ has joined #ruby
dbgster has joined #ruby
<Transcended>
Hello, I just installed ruby 1.9.1 on ubuntu 11.04. Is there an easy way to upgrade to 1.9.3?
ph^ has joined #ruby
apeiros_ has joined #ruby
<kandinski>
Transcended, in #ubuntu they can tell you how to find more up to date packages
nowthatsamatt has quit [#ruby]
<DrAwkward>
kandinski: Hash.new?
<DrAwkward>
I mean what is Hash(something) supposed to do?
thone_ has joined #ruby
<kandinski>
Dr, create a new Hash with the given parameters, I guess. I do come from a Python background, where classes are callables
<DrAwkward>
Well
<kandinski>
your question has made me realise this is not true for Ruby, thanks
<DrAwkward>
I suggest you do Hash.new(*a.zip(b))
<kandinski>
ta
mikeycgto has joined #ruby
mikeycgto has joined #ruby
Sailias has joined #ruby
gen0cide_ has joined #ruby
snip_it has joined #ruby
<DrAwkward>
kandinski: Won't work sorry
td123 has joined #ruby
<DrAwkward>
I thought it would
<kandinski>
Hash.new(*(a.zip(b))) doesn't either
<DrAwkward>
But it doesn't
<DrAwkward>
Yeah
<DrAwkward>
I was wrong
<DrAwkward>
Sorry about that
<kandinski>
no worries, thanks for answering
<DrAwkward>
Sorry man
<kandinski>
apparently Ruby only wants zero or one arguments to Hash.new
<DrAwkward>
I forgot flatten
<DrAwkward>
hehe
<DrAwkward>
Try
<DrAwkward>
Hash.new(*a.zip(b).flatten)
<rburton-_>
having a hard time finding out if bunny is thread-safe or how it should be used in a thread safe manner from a publisher perspective
<DrAwkward>
And loose the .new
<DrAwkward>
Damn, Imma go shoot myself now
<DrAwkward>
:/
<kandinski>
no worries
<kandinski>
you are clearly thinking out loud
<DrAwkward>
Hash[*a.zip(b).flatten]
<kandinski>
wha?
<DrAwkward>
Nah that was mental diarrhea
<DrAwkward>
This one should work now
<kandinski>
not a callable, but you create a new hash by subscripting Hash?
farhankhalaf has joined #ruby
<kandinski>
DrAwkward: it worked. I also see that * has the lowest priority of all the things inside the square brackets
<kandinski>
not that I want to pick up a fight, but in two weeks of studying Ruby while doing the Rails tutorial this is about the second thing that's not terser than the equivalent python -- dict(zip(a,b)), for anyone intersted --
<kandinski>
so please if anyone has a terser idiom, I will appreciate it
mmokrysz has joined #ruby
<kandinski>
and thanks DrAwkward for the solution!
mmokrysz has quit [#ruby]
igaiga has joined #ruby
tayy has joined #ruby
john_smith has joined #ruby
<matled>
kandinski: Hash[a.zip(b)]
<kandinski>
matled: ah, thanks
<kandinski>
matled, can you explain to me why ruby uses the method []?
somazero has joined #ruby
<matled>
kandinski: well, I find it a bit inconsistent too. in general it's an easy way to make an object (in this case a class) callable without the overhead of typing .call or something like that
<matled>
kandinski: i.e. for procs #[] is the same as #call
stringoO has joined #ruby
burns180 has joined #ruby
<kandinski>
matled, I see, thanks
<kandinski>
matled, but you can't assign procs to variables, or is there a trick for that?
<matled>
sure. foo = proc { puts Time.now }
<kandinski>
matled, ah sure, I was trying straight p = { |x| puts x }
<kandinski>
this is neat
<kandinski>
matled, thanks a lot
rburton- has joined #ruby
tayy has joined #ruby
mashpeloton has joined #ruby
mickn has joined #ruby
chimkan has joined #ruby
tommyvyo has joined #ruby
machine1 has joined #ruby
interlocutor has joined #ruby
interlocutor has quit [#ruby]
stephenjudkins has joined #ruby
stephenjudkins_ has joined #ruby
rellin has joined #ruby
<rellin>
I'm using a big library which I don't understand too well and running into a weird heisenbug. Through playing with rdebug, I found that adding 'pp object' at a certain place fixes the issue. 'p object' doesn't fix the problem. Anyone know how I can easily emulate pp's behavior without all the stdout lag? :)
SashaGrey89 has joined #ruby
shadoi has joined #ruby
<banistergalaxy>
SashaGrey89: she was born in 1988!
<banistergalaxy>
:)
burns180_ has joined #ruby
yoklov has joined #ruby
Transcended has joined #ruby
ed_hz_ has joined #ruby
mashpeloton has joined #ruby
j3r0m3 has joined #ruby
kwertii has joined #ruby
timonv has joined #ruby
<rellin>
I figured it out. s = object.inspect
<rellin>
totally unnecessary and stupid but there it is. :(
<banistergalaxy>
rellin: how does that cause a bug? did u look at source for the inspect method? is it changing some state somehow?
<rellin>
banistergalaxy: beats me. I'm guessing it calls some sort of function on the object implicitly which fixes it up somehow.
<banistergalaxy>
rellin: why dont u read teh source and follow it through? :P
<rellin>
banistergalaxy: it's a big library and a popular but rarely-changed project. datamapper. :|
<banistergalaxy>
rellin: i mean follow through #inspect
<banistergalaxy>
look at the methods it calls and see how it could possibly have any affect
<banistergalaxy>
effect
<rellin>
banistergalaxy: hmm not sure if rdebug goes through all the contructors or whatever it's calling.
<banistergalaxy>
rellin: is it a C method or a ruby method?
<rellin>
banistergalaxy: #inspect? probably a ruby method, but I'm not sure.
<rellin>
banistergalaxy: I see the problem. This library implemented its own inspect method. I'm looking at a line which looks like this: "#<#{self.class.name}>". Is there somewhere to learn about this syntax?
machine1 has joined #ruby
<Boohbah>
#{} will just expand what's inside it
<banistergalaxy>
rellin: #{} calls to_s on its context and inserts that at thta point in the string
tayy has joined #ruby
rellin_ has joined #ruby
shtirlic_ has joined #ruby
artOfWar has joined #ruby
jergason has joined #ruby
blazento has joined #ruby
<DrAwkward>
My question might actually be a better fit for this channel
dv310p3r has joined #ruby
burns180 has joined #ruby
<DrAwkward>
I'm calling a method with two parameters, the second one being a hash of options. Yet when I inspect the options parameter in the body of the method, it says its an Array
<DrAwkward>
Any idea as to why?
<DrAwkward>
An array with one element, containing my hash of options
rickmasta has joined #ruby
Sailias has joined #ruby
jergason has joined #ruby
bglusman has joined #ruby
sacarlson has joined #ruby
CacheMoney1 has joined #ruby
m0rt3st has joined #ruby
<shevy>
what
<shevy>
always best to have sample code ready
<shevy>
and to show case
<shevy>
words alone are inaccurate
<shevy>
oops
<shevy>
and to show code
<shevy>
not case
Sailias has joined #ruby
pu22l3r has joined #ruby
igaiga has joined #ruby
redgetan has joined #ruby
odinswand has joined #ruby
burns180_ has joined #ruby
zulax has joined #ruby
fayimora has joined #ruby
zakwilson has joined #ruby
Quirrell has joined #ruby
Quirrell has joined #ruby
MasterOfPuppets has joined #ruby
yugui has joined #ruby
<MasterOfPuppets>
Hi ppl
n1xjunk13 has joined #ruby
<MasterOfPuppets>
I'm learning ruby, can anyone help me with "method_missing"?
mikeric has joined #ruby
mikepack has joined #ruby
sroy2 has joined #ruby
wataken44 has joined #ruby
banister_ has joined #ruby
Naith has joined #ruby
bglusman has joined #ruby
kyledr_ has joined #ruby
emmanuelux has joined #ruby
VoiDeT has joined #ruby
burns180 has joined #ruby
<VoiDeT>
How can i construct a datetime object with the numerical day number of the year?
<wroathe>
Yeah. I'm actually curious where the method "include" is defined.
<wroathe>
No
<wroathe>
That's not it.
<wroathe>
I'm just messing around with Ruby's object model and I'm wondering if there's a way to monkey patch include to allow the inclusion of Classes instead of Modules as mixins.
tomb has joined #ruby
robbyoconnor has joined #ruby
ansii has joined #ruby
<shevy>
wroathe it boggles the mind
<cout>
wroathe: it's possible, but it's not something that you should do.
<shevy>
there should have never been the separation between module and classes in the first place
<shevy>
that way, what wroathe wants to do would have been possible in the first place too
<shevy>
but now, you are stuck wroathe!
<shevy>
I wonder why subclassing is not called a mixin
<shevy>
it seems a fairly arbitrary definition to define one add-on of behaviour subclassing, the other one as a mix-in
<cout>
shevy: mixing in is a different mechanism from subclassing
<shevy>
yeah, it's more crippled
<cout>
shevy: when you mix-in, you are inheriting from a proxy class
<shevy>
you still get functionality
<shevy>
some methods
r0bby has joined #ruby
rramsden has joined #ruby
<shevy>
well perhaps there was a clear reason matz decided to go that way
<shevy>
like C++ hate or something
<cout>
it has nothing to do with C++
Sailias has joined #ruby
Synthead has joined #ruby
<shevy>
hmm I dont find the old interview :(
<Boohbah>
include is a private instance method of Module
<shevy>
"Mix-ins originally started in LISP culture"
<shevy>
anyone know what that means or how lisp uses mixins?
<Boohbah>
p Module.private_instance_methods
<Boohbah>
cool :)
looopy has joined #ruby
auraka_ has joined #ruby
<shevy>
well
<shevy>
I want instant and perfect C knowledge
<shevy>
where are the module chips? wasn't this promised to us in science fiction movies
badabim has joined #ruby
araujo has joined #ruby
snip_it has joined #ruby
rippa has joined #ruby
burns180 has joined #ruby
manizzle has joined #ruby
tommyvyo has joined #ruby
drbawb has joined #ruby
dhruvasagar has joined #ruby
burns180_ has joined #ruby
noyb has joined #ruby
swarley has joined #ruby
seanstickle has joined #ruby
<swarley>
I need some thoughts on how to do something with probability. Like, if a number is higher, say 146, it has a higher probability than if the number is 12
<swarley>
higher probability of being true*
odinswand has joined #ruby
thecreators has joined #ruby
fbernier has joined #ruby
burns180_ has joined #ruby
john has joined #ruby
bier has joined #ruby
<rippa>
swarley: number being true?
igaiga has joined #ruby
<banister_>
swarley: there has to be an upper limit
<swarley>
there is
<banister_>
swarley: and what is it
<swarley>
that being the value of the number
<swarley>
0..x
<banister_>
swarley: then take N as a percentage of x
<banister_>
swarley: u know about percentages right? :P
<swarley>
Well yes
<banister_>
so, N/x
nikhgupta has joined #ruby
<swarley>
what would i compare that against?
<banister_>
swarley: you're not giving enough details tbh
<swarley>
its difficult to explain
<swarley>
maybe just for me though
<banister_>
if your upper limit is 200 and you're given 146, then take 146/200.0 * 100 to find the percentage
<swarley>
i'm making a markov chainer
<banister_>
likewise for 12, 12/200.0 * 100
cobragoat has joined #ruby
sgharms has joined #ruby
<sgharms>
Is there a reliable way to get content_type from a file in ruby 1.8.7?
philcrissman|afk has joined #ruby
TheMoonMaster has joined #ruby
kevinbond has joined #ruby
kevinbond_ has joined #ruby
fbernier has joined #ruby
nate_h has joined #ruby
burns180_ has joined #ruby
somazero has joined #ruby
tommyvyo has joined #ruby
fbernier has joined #ruby
looopy has joined #ruby
akem has joined #ruby
dipix has joined #ruby
looopy_ has joined #ruby
blueadept has joined #ruby
blueadept has joined #ruby
djdb has joined #ruby
Sailias has joined #ruby
JohnBat26 has joined #ruby
x0F_ has joined #ruby
burns180 has joined #ruby
sgharms has quit [#ruby]
<qurve>
Am I missing something or can you not look up SPF records using Resolv::DNS?
<qurve>
Playing with that now, but not understanding it's return values.
<qurve>
I can query for SPF records, but I get back this obscure Dnsruby::Message::Section object which really just looks like a raw line from a dns response.
<qurve>
I guess I can parse through it, but it's weird. Resolv returns pre-parsed objects that are very clean :)
<qurve>
I'll deal with this one later, very annoying :)
A124 has joined #ruby
r0bby has joined #ruby
burns180_ has joined #ruby
Transcended has joined #ruby
manizzle has joined #ruby
djdb has joined #ruby
drake has joined #ruby
drake10 has joined #ruby
badabim has joined #ruby
nemesit has joined #ruby
cableray has joined #ruby
luckyruby has joined #ruby
burns180 has joined #ruby
odinswand has joined #ruby
Beoran has joined #ruby
Prezioso has joined #ruby
symb0l has joined #ruby
srji has joined #ruby
tk_ has joined #ruby
samsonjs has joined #ruby
hyper_ch has joined #ruby
<hyper_ch>
hi there, I somehow messed up RVM on my box. For a given user when I run rvm install ruby-1.9.2-p290 it tries to instal it in a different user's account
ylluminate has joined #ruby
i8igmac has joined #ruby
samsonjs has joined #ruby
burns180_ has joined #ruby
Beoran has joined #ruby
<Mon_Ouie>
You installed RVM separately for both users? (i.e., you're not using the RVM from user A with user B)?
<hyper_ch>
Mon_Ouie: I only installed rvm for one user
<hyper_ch>
but somehow it ended up wanting to install in the other user's
<hyper_ch>
I solved it now by exporting rvm_path in .bashrc
<hyper_ch>
not pretty but that fixed it
cmasseraf has joined #ruby
zakwilson has joined #ruby
hyper_ch has quit ["Konversation terminated!"]
somazero has joined #ruby
DrAwkward has joined #ruby
JohnBat26 has joined #ruby
artm has joined #ruby
burns180 has joined #ruby
wataken44 has joined #ruby
Gesh has joined #ruby
Elfix has joined #ruby
Nss has joined #ruby
wataken44 has joined #ruby
nikhil_ has joined #ruby
<nikhil_>
hi, i'm reading through the Coursesa SaaS course book, and there is a self-check exercise that asks you to write one line of ruby which checks if s1.downcase == s2.downcase.reverse (a palindrome)
<nikhil_>
i have managed to construct a rather complex solution
<nikhil_>
s1.split(/(\W+)/).reject { |word| word =~ /\W|^$/}.join('').downcase == s2.split(/\W+/).reject {|word| word =~ /\W|^$/}.join('').downcase.reverse
<nikhil_>
is there an easier way?
macmartine has joined #ruby
OpenJuicer has joined #ruby
randym_ has joined #ruby
burns180_ has joined #ruby
swarley has joined #ruby
KL-7 has joined #ruby
nachtwandler has joined #ruby
ap0gee has joined #ruby
<ninegrid>
nikhil_: yes
<nikhil_>
ninegrid, care to elaborate?
<ninegrid>
i would after the 19th
<ninegrid>
make that the 13th
tewecske has joined #ruby
adambeynon has joined #ruby
<ninegrid>
nikhil_: what you can do is attempt to modify your regex so that you do not need split/reject... you only need to use gsub
<nikhil_>
ninegrid, it's still a solution, so i'm not really gaining anything except learning. but thanks for the tip :)
<ninegrid>
nikhil_: and you only need to use it twice
<nikhil_>
gsub
<ninegrid>
nikhil_: indeed, but robbing you of the process would only soften your ability to get better later
<nikhil_>
this is truth
<ninegrid>
nikhil_: the book is not a complete documentation of ruby though
<nikhil_>
true, that being said
<ninegrid>
iirc the book reminds you to use other sources
<kandinski>
if I compare two hashes with ==, will the comparison be true if they have the same values for the same keys, even if they are in different order, etc?
<Mon_Ouie>
foo "one", "two", "three"
<shevy>
ignore what I wrote wadkar :D
<wadkar>
shevy: thats okay, I think I got what you were trying to say after looking at Mon_Ouie 's example
<shevy>
should have been .... foo "one","two","three" instead
<Mon_Ouie>
kandinski: Yes. Hashes (normally) are unordered
<kandinski>
Mon_Ouie: thanks
<shevy>
so you can use as many parameters as you want to that method
dql has joined #ruby
<shevy>
they all get stored into the variable there
Richmond has joined #ruby
<wadkar>
and if I try to access say args[42] while I just passed two arguments, I will get some kind of error right ?
trivol_ has joined #ruby
<shevy>
well
<shevy>
the behaviour is just like with every other array too
sacarlson has joined #ruby
<wadkar>
I basically want to make sure args[0] is accessible or I raise exception/return some default
<shevy>
if the position at 42 does not exist, it prbably returns nil
dbgster has joined #ruby
<JonnieCache|home>
it returns nil yes
<JonnieCache|home>
so there is no error
<JonnieCache|home>
but you will instead get an error when you try to do something with that nil, expecting it to be something else
<wadkar>
shevy: ohh, thats great, and nil.to_s is defined ("") so, thats great
<shevy>
wadkar but you know how to use arrays in ruby right :D
<wadkar>
shevy: I am learning , so not really :)
<shevy>
hehe
<shevy>
well
<shevy>
hashes ... arrays ... strings ... that's the basics
Richmond has joined #ruby
<wadkar>
JonnieCache|home: got that, i think I will have to utilize the nil? method a lot
<shevy>
without those basics, understanding "def method_missing(name, *args, &block)" is harder
<wadkar>
shevy: not when you have to submit an assignment in two hours :P
<JonnieCache|home>
wadkar: you shouldnt actually have to use nil? much if you remember that nil evaluates to false in comparisons
<shevy>
yeah but
<shevy>
is there a ruby afterlife
<shevy>
or will you use it only for two hours :P
<JonnieCache|home>
you can get more elegant code if you use that rather than nil? imo
<kandinski>
falsies
<wadkar>
shevy: I dont see any immediate use of ruby (unless my company decides to abandon the Java-ship and jumps on the RoR wagon)
<shevy>
awwww
<shevy>
Java!
<JonnieCache|home>
heh
<wadkar>
JonnieCache|home: can you please give me a simple example of what you are trying to say ?
<shevy>
hey JonnieCache|home ... are you at work?
Richmond has joined #ruby
<JonnieCache|home>
a = nil; if a; puts "this wont print"; end
<JonnieCache|home>
is the same as
<JonnieCache|home>
a = nil; if !a.nil?; puts "this wont print"; end
<JonnieCache|home>
basically in ruby, everything is true except false, and nil
ph^ has joined #ruby
<wadkar>
ohh, so that a.nil? is unnecessary
<canton7>
so, unless you actually need to distinguish between false and nil, there's normally not much need to use #nil?
squidz has joined #ruby
<JonnieCache|home>
you only need nil? if you really really need to check if youve definitely got nil
<squidz>
does anybody know how to get a pages URL with mechanize?
IAD has joined #ruby
<JonnieCache|home>
and in practice thats not often
<squidz>
does anybody know how to get a pages URL with mechanize?
<wadkar>
JonnieCache: so my ' @amount_in_dollar = self if @amount_in_dollar.nil? ' can be simply put as ' @amount_in_dollar ||= self ' ?
<wadkar>
s/self/1/
<JonnieCache|home>
yes indeed
<shevy>
squidz, to get the page, page = agent.get(url)
<shevy>
usually you known the URL you want to fetch
<shevy>
:P
artm has joined #ruby
timonv has joined #ruby
artm has joined #ruby
burns180_ has joined #ruby
malkomalko has joined #ruby
shtirlic has joined #ruby
mickn has joined #ruby
burgestrand has joined #ruby
LMolr has joined #ruby
john_smith has joined #ruby
<banister_>
burgestrand: have you seen 'headhunters' ? the new norwegian/danish film
<burgestrand>
banister_: nope, a bit busy now though :p
<wadkar>
how can I give a default value to an instance variable ? (dont want to redefine constructor , I have just opened the numeric class)
<banister_>
wadkar: @ivar ||= :pig
<apeiros_>
ew
<wadkar>
can I do : class Numeric ; @in_dollar = self ; end
<apeiros_>
wadkar: think about to what that @in_dollar belongs
<wadkar>
and then define other methods which will play with @in_dollar as they wish without having to @in_dollar ||= self everytime it is called upon?
neurodrone has joined #ruby
<apeiros_>
hint, it belongs to whatever is self there, and self there is Numeric (not an instance of Numeric)
neurodrone has joined #ruby
<wadkar>
apeiros_: ooh, thats bad ... so I should @in_dollar = self , unless I am inside a method ? that makes sense ! how can I assign self unless I am sure I have instantiated an object !
thecreators has joined #ruby
<wadkar>
but, class Foo; @var; end #=> @var is nil by default
<wadkar>
right ?
artm has joined #ruby
<wadkar>
I am defining Numeric#in(currency) , should I call super in case the args are not right/something bad happens?
<shevy>
wadkar, usually it is better to not have instance variables appear outside of methods
etehtsea_ has joined #ruby
k_89 has joined #ruby
<shevy>
I myself tend to write an own method that does all initialization of instance variables, and call that from within initialize()
jglauche__ has joined #ruby
yeggeps has joined #ruby
<k_89>
hey .. where can i find a decent explanation of class << self; end; thing which is used to define static methods in a class
<k_89>
and what's the best practice regarding the static thingy . def self.method, def ClassName.method, or class << self; def method { } end
etehtsea_ has joined #ruby
<shevy>
wadkar I was referring to: " class Foo; @var; end"
<canton7>
wadkar, why not define your own class, Currency, which inherits from Numeric. Monkey-patch Numeric to have #dollar, etc, but make that return an instance of Currency
<nikhil_>
could anyone explain what the directory structure should be to use this https://github.com/tapichu/saas-class/ to test a file i have called hw1_part1.rb
<nikhil_>
?
<shevy>
k_89 "def ClassName.method" is less flexible than "def self.method"
timonv has joined #ruby
<wadkar>
canton7: because I have been asked to redefine the Numeric class :)
<JonnieCache|home>
the deadline for the MIT class is tonight :)
sohocoke has joined #ruby
timonv has joined #ruby
<k_89>
shevy, thanks for the reply .. you know some resource where i can read about the class << self thing
<wadkar>
JonnieCache|home: s/MIT/SaaS(coursera)/
<k_89>
tried a google search .. nothing helpful came up
peterhil has joined #ruby
<JonnieCache|home>
coursera is MIT isnt it?
<wadkar>
nope, Stanford
<JonnieCache|home>
ahhh
<shevy>
k_89 usually you can search indirectly. "class methods ruby self" should yield something useful
<nikhil_>
nope, Berkley
<wadkar>
but SaaS is conducted by UCB prof(s)
<shevy>
just think of "class << self" as extending self
<canton7>
wadkar, then either set @amount_in_dolalrs somewhere sensible, or use "(@amount_in_dollars || self) / @@currencies[currency]" maybe?
<wadkar>
nikhil_: coursera infra is stanfy, individual course are from various "UC(X)"
<nikhil_>
wadkar, ah
<JonnieCache|home>
dont know why i thought it was MIT
<nikhil_>
wadkar, could you help me with the git issue posted above?
<wadkar>
canton7: I thought about that, but its more clear to me when I read it along with the comment
<shevy>
canton7 hah
<shevy>
@amount_in_dolalrs
<k_89>
thanks man^^
<shevy>
these are the coolest bugs :D
<shevy>
all my dollolololars!
ikaros has joined #ruby
<canton7>
hehe
* canton7
coins a new currency
<canton7>
wadkar, I wasn't suggesting you remove the comment
<wadkar>
nikhil_: sorry mate, never did unit tests (and ruby is totally new for me)
<canton7>
wadkar, and one point -- I believe 2.0.yen.euro will not produce the correct result?
<nikhil_>
thanks wadkar
<wadkar>
canton7: ohhk, hmm it does makes sense when I give a second look
<wadkar>
canton7: works for me
burns180_ has joined #ruby
<wadkar>
canton7: sorry, doesn't
* wadkar
adds unit-tests to his to do list
<canton7>
wadkar, as the second #euro converts the original value, 2.0 dollars, to euros, when it should be converting 2.0 yen to euros
<JonnieCache|home>
wadkar: the output you get when they grade your excercises is produced by rspec, the leading ruby unit testing framework
<wadkar>
canton7: yes, I got your point
<JonnieCache|home>
just to get you started :)
<wadkar>
JonnieCache|home: yep, saw that name in the output of my failed attempts :)
<JonnieCache|home>
rspec is pretty great
dekroning has joined #ruby
<JonnieCache|home>
testing in general will hurt your brain though
OpenJuicer has joined #ruby
virunga has joined #ruby
<john_smith>
testing is wonderful
<dekroning>
when you executer a class method, the constructor of that class is not executed right ?
<wadkar>
JonnieCache|home: yeah, I just tried 5.rupee.rupee and thought I should get 5 in return, but I ain't , its already driving me nuts
<wadkar>
when I think about it, when I am saying 5.rupee.in(:rupee) , I should get 5 , and thats true , but when I do 5.rupee.rupee , what should I get ?
Beoran has joined #ruby
<apeiros_>
(other than the obvious "write docs & tests")
<apeiros_>
wadkar: 5 rupees
<apeiros_>
wadkar: i.e. an object with the number and the unit
<apeiros_>
at least that's what I'd expect
medik has joined #ruby
<wadkar>
apeiros_: errm, yeah, I thought so, but this is part of assignment, so I think I should better submit my work and checkout the actual test cases, which will tell me exactly what is expected
<wadkar>
OTOH , if I say every numeral is by default in dollar, and 5.ruppes will return whatever the value is in dollar, then 5.rupee.rupee should return me double conversion (rupee => dollar)
ikaros has joined #ruby
<canton7>
I'd be tempted to say 5.rupee.rupee should be forbidden. You've got the 'in' method for doing conversions
akem has joined #ruby
<Mon_Ouie>
apeiros_: with \b, isn't that more like 'capitalize_words'?
<apeiros_>
Mon_Ouie: aaaah, damit, misnomer, yes, of course. that's what the name should be :)
eldariof has joined #ruby
<apeiros_>
Mon_Ouie: thanks :) changed
<apeiros_>
somebody needs to poke josh, pastie's syntax highlighting is broken :(
<wadkar>
canton7: hmm, thats a good argument, I think I will submit my hoemwork and see how it goes
* wadkar
is opening String class now
<shevy>
whoa :P
<shevy>
a java guy changing a core class
<shevy>
that is scary
<shevy>
;P
<wadkar>
how do I add a method to enumerable module ?
<shevy>
just as with any other module too
<shevy>
module Bla; def lala; puts "lalalalala"; end; end
<apeiros_>
shevy.lala
<wadkar>
shevy: sweet ! thats supercool !
<shevy>
lala is one of the most underestimated method out there ever
<wadkar>
Enumerable have reverse, right ? orr wait, let me read the docs myself
<apeiros_>
wadkar: btw., in most western languages, having a space in front of punctuation is wrong (e.g. "how … to module ?" --> "how … to module?")
<shtirlic>
is it possible to use em-synchrony with sqlite for development env?
<Mon_Ouie>
It's not wrong in French, though (for some punctation marks)
<emocakes>
que ?
<shevy>
it only has #reverse_each though
<apeiros_>
Mon_Ouie: yes, but french doesn't use a space, it uses a 1/4 space
<wadkar>
apeiros_: thanks, I didn't know that! What was I thinking? I hope this is right.
<apeiros_>
wadkar: yupp, it is :)
<dekroning>
anyone that could tell me when exactly the constructor (def initialize … end) is executed?
<emocakes>
when you make a new one of it dekroning
<emocakes>
:p
<dekroning>
emocakes: only when doing Object.new ?
<shtirlic>
dekroning: .new method
<Mon_Ouie>
new is a class method that allocates an object and calls initialize on it before returning
<dekroning>
emocakes: or does it also means Object.instance_method
<dekroning>
ok so when i'm doing purely an instance method call to an object, the constructor is not called
<shtirlic>
dekroning: after the object is created - no
<wadkar>
shevy: that'll do , as not passing a block to #reverse_each returns a copy of the enumerator in reverse order, which I can compare with original to get what I want :)
<Mon_Ouie>
No, that's why it's the "initialize" method: it is only called to initialize it, right after its creation
burns180 has joined #ruby
burns180 has joined #ruby
<dekroning>
shtirlic: del i'm no where calling the Object.new just directly doing Object.instance method
<dekroning>
shtirlic: reason i'm asking, is that I initialize some instance variables in my initializer that this class method needs
<dekroning>
or sorry previous sentence I mean "just directly doing Object.class_method"
<Mon_Ouie>
You can't access the instance variables of an instance of Foo from a class method in Foo
<shtirlic>
Mon_Ouie: but if this class have something like current_object, he can ;)
<cout>
shtirlic: in that case you're breaking OO
<cout>
might as well just make everything global at that point
<shtirlic>
cout: sure ;)
<shtirlic>
php globals on
<wadkar>
ouch ! Enumerators are like pointers, they dont carry the whole array themselves it seems
<Mon_Ouie>
They are lazy, they won't call the method until it is actually needed
emmanuelux has joined #ruby
<wadkar>
how do I traverse two Iterators hand in hand (one is reverse of other, I just want to compare what they point to at each iteration)
visof has joined #ruby
<apeiros_>
wadkar: Enumerable#zip
<wadkar>
and it'll be nice if I can iterate over just the half the size of the Enumerable (its pointless to do a full one)
<apeiros_>
you can break at any point
<Mon_Ouie>
And use methods like all? or any?, which will return as soon as possible
sgmac has joined #ruby
sgmac has quit [#ruby]
<Mon_Ouie>
But Enumerable#reverse_each sounds rather pointless, because it has to store all the objects in some kind of container anyway (it uses an array, most likely)
<wadkar>
apeiros_: didn't understand zip at all , I basically want to compare elements of enumerable to each other, I might as well do self.each if only each provided me the index/key of the element !
<cout>
irb(main):005:0> a = [1, 2, 3]; p a.each.zip(a.reverse_each)
<cout>
[[1, 3], [2, 2], [3, 1]]
<cout>
wadkar: see above
<apeiros_>
wadkar: zip works like a zipper (the thing in front of your trousers)
<apeiros_>
in the front-side of…
<wadkar>
apeiros_: got it, no need to TMI
<apeiros_>
o0
artm has joined #ruby
schovi has joined #ruby
<wadkar>
cout: apeiros_ : the docs say that I can also use a block, I am not sure how do I use it .. I mean , a.zip(a.reverse_each) { |foo| #do I only get foo? what is foo ? }
seanstickle has joined #ruby
<canton7>
to use count's example, a.each.zip(a.reverse_each){ |foo| p foo } ... on the first iteration, foo will be [1, 3]
<apeiros_>
canton7: .each.zip is somewhat redundant
<apeiros_>
unless you have a fucked up class which has each but isn't Enumerable
<canton7>
apeiros_, i literally copy-pasted it :P
<apeiros_>
canton7: you literally didn't use your brains then
<canton7>
apeiros_, I literally pasted it, wondered about it, psoted it anyway, then fired up irb :P
<apeiros_>
you literally failed
<apeiros_>
:-p
<apeiros_>
you can quote me literally about that :D
<cout>
wadkar: if you pass a block, you won't be able to iterate both arrays at once
shtirlic has joined #ruby
<apeiros_>
cout: um, yes, you are?
<apeiros_>
but zip with a block won't return a zipped array anymore (it returns nil)
<cout>
wadkar: if you don't pass a block, then #each and #reverse_each return Enumerator objects
<canton7>
I've literally redeemed myself: irb(main):034:0> a.zip(a.reverse){ |f| p f } :)
<cout>
apeiros: oh zip with a block? I thought he meant #each with a block.
<wadkar>
I would really like to know how zip works, but I think all I really need to do is reform/get an object after #reverse_each , which should be simple if I just do reversed_a = a.reverse_each { |x| x }
<cout>
I shuld lern 2 rede
norex has joined #ruby
<cout>
wadkar: if you want to go that route then just use ra = a.reverse
<apeiros_>
wadkar: I told you how, but you didn't want TMI…
<canton7>
wadkar, if you call [1, 2, 3].zip([4, 5, 6]), you get an array of [[1, 4], [2, 5], [3, 6]]
<wadkar>
cout: Enumerable doesn't have #reverse defined
<cout>
wadkar: oh, it's not an array?
<wadkar>
apeiros_: I was referring to part of the trousers '...' :P not to ruby related stuff
<apeiros_>
anyway, my wife complains, I should pay more attention to making love to her right now
<cout>
apeiros_: again with the TMI!
<canton7>
banister_, that's Array#reverse_each. We were talking about Enumerable#reverse_each
<apeiros_>
cout: what what whaaat?!?
<apeiros_>
cout: what's wrong now?!?
<banister_>
apeiros_: bust a double horizontal on her ass
<cout>
apeiros_: don't forget to use Wife#unzip
<banister_>
canton7: isn't he using an Array?
steampunkee has joined #ruby
<canton7>
banister_, we thought he was, then "<wadkar> cout: Enumerable doesn't have #reverse defined" happened
<steampunkee>
what's the proper way to check if either element of an array represents a string in a hash?
<shevy>
why not Wife#mute
<canton7>
steampunkee, give us an example of that data structure?
<shevy>
steampunkee .is_a? String
<wadkar>
banister_: I am writing the simple Enumerable#palindrome? ; self == self.reverse_each { |x| x } ; end for now , but I will keep your external iterators in mind
<steampunkee>
([1,2,3].select do { |k| hash.has_key?(k) } == nil) #i'm hoping for something more succinct than this
<cout>
shevy: "represents" and "is a" aren't quite the same. we need more clarification on what his question is.
<steampunkee>
remove that do
<steampunkee>
canton7: shevy: above.
hasrb has joined #ruby
<shevy>
hehe
<banister_>
steampunkee: by 'either' u mean 'any' ?
<wadkar>
Mon_Ouie: kewl, that works, but I don't grok a single word/part of it!
<wadkar>
:(
* wadkar
decides to re-read the Enumerable#zip documentation
nikhil_ has joined #ruby
<Mon_Ouie>
all? returns true if the block returns true for all the items of the enumerated object
kirun has joined #ruby
<banister_>
and it early-exits on the first false
wroathe has joined #ruby
<wadkar>
Mon_Ouie: hmm, so my loop { ... } is (like) #all? but zip(reverse_each) will still create a new array ? or the elements would simply be pointers to the old Enumerable@elements?
visof has joined #ruby
* wadkar
has to stop putting spaces between words and ? (though this is perfectly correct usage :P )
<cout>
wadkar: sometimes the space is necessary to avoid ambiguity
<cout>
i.e. did you mean elements? or elements ?
<wadkar>
cout: hmm, agreed
<Mon_Ouie>
Your loop is wrong, also: enum.next will raise an Exception if there are no more elements to iterate over
<banister_>
Mon_Ouie: that exceptino is rescued silently by loop {} and loop terminates
<wadkar>
Mon_Ouie: hmm, I didn't get Exception when I tried
<banister_>
yeah
<wadkar>
woha, thats ruby source ??
<rippa>
yes
* wadkar
damn! again spaces!!
<steampunkee>
is there something like .merge for hashes which only copies specified keys from other_hash to the original one?
artm has joined #ruby
<rippa>
steampunkee: create new hash with needed keys, merge it
<rippa>
(#select)
<wadkar>
are String Enumerable?
<rippa>
no
Chickenninja has joined #ruby
<Mon_Ouie>
But you can use String#each_char or #each_line or #each_byte, depending on what you want to do
<Chickenninja>
can anyone offer a quick hand?
codebeake has joined #ruby
norex has joined #ruby
<Chickenninja>
got a script that identifies a spacific file on a remote webserver. its a 302 response i want. but redirects are not always the same except in the url for this framework. how do i use "include?" and have it look in the url for a string to match?
* wadkar
is superhappy to score 100/100 on first attempt!! \m/
<wadkar>
thank you guys, learnt a lot! (still 2-3 parts are remaining)
<rippa>
in russia, you have to score at least 146/100
<cout>
rippa: in soviet russie, at least 146/100 has to score you!
td123 has joined #ruby
codebeake has joined #ruby
<wadkar>
rippa: cout: 146.49, to be precise :P
<wadkar>
s/49/47/
shtirli__ has joined #ruby
burgestrand has joined #ruby
burns180 has joined #ruby
artm has joined #ruby
sohocoke has joined #ruby
TaTonka_ has joined #ruby
AxonetBE has joined #ruby
schovi has joined #ruby
wataken44 has joined #ruby
porco has joined #ruby
yxhuvud has joined #ruby
nikhil_ has joined #ruby
wroathe has joined #ruby
QKO has joined #ruby
sohocoke has joined #ruby
pongwon has joined #ruby
mr_blue has joined #ruby
burns180_ has joined #ruby
schovi has joined #ruby
<steampunkee>
i want GET variables to be passed, why doesn't this do the job: redirect_to target_path(params)?
neurodrone has joined #ruby
neurodrone has joined #ruby
<steampunkee>
wrong room
twock has joined #ruby
EvanR has joined #ruby
<steampunkee>
is there a way to list common keys of two hashes?
ceej has joined #ruby
<steampunkee>
without iterating and asking has_key?
<wadkar>
how do I return an iterator ? is there any special syntax ? or do I have to simply include Enumerable and define #each ?
<Mon_Ouie>
Did you mean an Enumerator?
<steampunkee>
-_-
<steampunkee>
wadkar: just define each and have it yield, that'd do it.
<wadkar>
Mon_Ouie: Enumerator, yes thats the right word in Ruby-context
<wadkar>
steampunkee: thats what I thought
<Mon_Ouie>
Enumerator.new(object, metohd_name)
<Mon_Ouie>
Typically you'd do return to_enum(__method__, *args) unless block_given?
<wadkar>
steampunkee: won't i require to include Enumerable in the class definition ?
<steampunkee>
wadkar: i thought that was implied.
<wadkar>
steampunkee: ohhk, thats what I said, but wanted to confirm again
* wadkar
is not sure where to find documentation for yield?!
<Mon_Ouie>
It's a keyword that just calls the block passed to the current method with whatever you pass to it
DarthGandalf has joined #ruby
sohocoke has joined #ruby
krz has joined #ruby
AxonetBE1 has joined #ruby
burns180 has joined #ruby
albemuth has joined #ruby
wroathe has joined #ruby
lateau has joined #ruby
Spockz_ has joined #ruby
fbernier has joined #ruby
sohocoke has joined #ruby
<xeno_>
hi, in rails/haml, if I do link_to "text", my_path("foo") - then foo will end up as "format" in the params hash. I guess this is not the intended use, what is the correct way of passing a single argument?
<tommylommykins>
hmm, am I right in thinking that blocks are not first class objects?
<tommylommykins>
I can't put them in an array?
Playb3yond has joined #ruby
<JonnieCache|home>
try calling &block.to_proc
dagnachewa has joined #ruby
<yoklov>
yeah, thats actually one of the only things about ruby which i think is inconsistent, the whole proc/lambda/method/block disparity
<JonnieCache|home>
yeah its a bit weird. i think maybe its like that because of some implementation constraint
mdw has joined #ruby
ap0gee has joined #ruby
<tommylommykins>
hmm, am I also right in thinking that you can only pass one block in to a method, so you can't do def my_method block1, block2; [block1.to_proc, block2.to_proc]; end
<tommylommykins>
(ignoring my dodgey syntax)
<yoklov>
pass them in as a lambda?
<yoklov>
you can keep those in an array too
<yoklov>
or if they're a method you should use a method object. blocks aren't really objects in ruby but the other things are
<yoklov>
i think.
<JonnieCache|home>
yeah thats right
drbawb has joined #ruby
drbawb has joined #ruby
zeninfinity has joined #ruby
burns180_ has joined #ruby
<yoklov>
yeah, that was actually why i stopped writing a lot of ruby code. coming from an FP background that was just... annoying.
philcrissman|afk has joined #ruby
<JonnieCache|home>
t least it aint pyhton
<yoklov>
right
* tommylommykins
has writted far more anonymous methods in ruby than he has in lisp :S
<tommylommykins>
but then again, I wasn't really the best with lisp..
<tommylommykins>
Well, if you count blocks... :P
<yoklov>
yeah i've done way more in lisp haha
<yoklov>
blocks in ruby are often used more like macros are in lisp
emocakes has joined #ruby
reitelles has quit [#ruby]
S1kx has joined #ruby
S1kx has joined #ruby
<tommylommykins>
/me stares at hsi questionable grammar
tess has joined #ruby
john_smith has joined #ruby
ap0gee has joined #ruby
<shevy>
lol
<shevy>
complete with typo eh ;)
dql has joined #ruby
atmosx has joined #ruby
swarley has joined #ruby
OpenJuicer has joined #ruby
snip_it has joined #ruby
<wadkar>
ohhk, now this might sound really n00bish question, but I just changed a link of one of my view template, what do I need to do to update it on the live system? like compile it from source and you know, do some rails-foo?
zommi has joined #ruby
macmartine has joined #ruby
* wadkar
is hiding in case somebody starts throwing rails documentation :-S
Foxandxss has joined #ruby
burns180 has joined #ruby
<JonnieCache|home>
you should just be able to refresh the page
<JonnieCache|home>
in development mode, the server reloads everything from disk with every refresh. thats why its so slow
<tess>
on
<JonnieCache|home>
(there are some things where you have to restart the server, like when you install new gems into your project)
philcrissman|afk has joined #ruby
<shevy>
waaaah
<shevy>
rails infiltration!
hubub has joined #ruby
<wadkar>
JonnieCache|home: thanks you very much, this is more like PHP in that sense, interpreted language
hubub has joined #ruby
<JonnieCache|home>
yep.
<wadkar>
shevy: I hope rails is allowed here, or do I need to go to #rails? (please let me stay here, I like this channel :D)
<JonnieCache|home>
theres #rubyonrails channel
<JonnieCache|home>
tbh rails discussions should really be there
<tommylommykins>
hmm, it appears that calling a proc with a variable number of arguments
<JonnieCache|home>
i do much prefer it here though
<tommylommykins>
where the variable number of arguments is 0
<tommylommykins>
is an error :(
waxjar has joined #ruby
<wadkar>
JonnieCache|home: hmm, well I will join #rubyonrails anyways, I hope I won't be too much of trouble if I ask silly/simple questions
<JonnieCache|home>
there are a lot more noobs in the rails channel :)
canton7 has joined #ruby
Gesh has joined #ruby
sbanwart has joined #ruby
<wadkar>
somebody had suggested me an interactive ruby shell, saying its like 'irb on steroids' , I forgot the name of it
snearch has joined #ruby
<wadkar>
will it help me for RoR docs? I really don't like the idea of Ctrl+F'ing through meter long doc-pages, I just want to know docs for a specific method; e.g. link_to rails method used to generate link in haml
<JonnieCache|home>
yes look into pry and its many features. you will have an advantage over the rest of the course :)
<wadkar>
thanks burgestrand , JonnieCache|home ; let me install it right away
<Mon_Ouie>
Also ri and YARD
<Mon_Ouie>
(for checking documentation; not as a ruby shell)
fudanchii has quit [#ruby]
<wadkar>
Mon_Ouie: hmm ri/YARD seem doc-specific gems, will add them as well
mikeycgto has joined #ruby
<wadkar>
I am assuming that the rails-stuff (gems) will generate their docs and I should be able to 'grep' them via pry/ri/yard ?
<tommylommykins>
'pry' sounds like it should be some python package :s
<Mon_Ouie>
Yes. Pry just uses either RDoc or YARD.
<Mon_Ouie>
(ri is the command-line tool to access RDoc documentaton)
<Mon_Ouie>
documentation*
<wadkar>
hmm, that means I will have to install these gems on AWS and not local (ruby versions are different)
zeninfinity has joined #ruby
<Mon_Ouie>
You should install the same ruby version on your development machine and on the machine the code will eventually run on
<wadkar>
Mon_Ouie: yes, my laptop isn't either of them, there is a small AWS instance where I am testing, and deploying it over heroku
CacheMoney has joined #ruby
schovi has joined #ruby
looopy has joined #ruby
burns180_ has joined #ruby
io_syl has joined #ruby
JNZ has joined #ruby
JNZ has joined #ruby
CacheMoney has joined #ruby
shruggar has joined #ruby
rickmasta has joined #ruby
Sailias has joined #ruby
pdtpatr1ck has joined #ruby
i8igmac has joined #ruby
InfiniteJest has joined #ruby
zul_ has joined #ruby
compcube has joined #ruby
emocakes has joined #ruby
flak has joined #ruby
lateau has joined #ruby
mdw_ has joined #ruby
looopy has joined #ruby
rippa has joined #ruby
tayy has joined #ruby
tommyvyo has joined #ruby
ph^ has joined #ruby
lateau has joined #ruby
zeninfinity has joined #ruby
blazento has joined #ruby
jgrevich has joined #ruby
adambeynon has joined #ruby
ank has joined #ruby
Sigma00 has joined #ruby
jgrevich has joined #ruby
rburton- has joined #ruby
daniel_hinojosa has joined #ruby
yoklov has joined #ruby
hasrb has joined #ruby
drbawb has joined #ruby
drbawb has joined #ruby
cmasseraf has joined #ruby
tolland has joined #ruby
luckyruby has joined #ruby
burns180 has joined #ruby
trivol has joined #ruby
ansii has joined #ruby
mashpeloton has joined #ruby
punsha has joined #ruby
<tolland>
hi, totaly newbie here. im trying open a text file with an flock, read it, mutate some text, and write it back again. i am specifying File.open(path,"r+:UTF-8") and truncate is defintiely removing the contents
gid0 has joined #ruby
<tolland>
but myfile.sysseek(0, IO::SEEK_SET) is isnorning my in the most despicable manner
<tolland>
oops, "ignoring me"
gid0 has joined #ruby
sohocoke has joined #ruby
<apeiros_>
why do you use sysseek?
demian`_ has joined #ruby
<tolland>
erm, its was in the example i found on google.
<tolland>
im on fedora so its ruby 1.8.7 maybe its old
Richmond has joined #ruby
<shevy>
if you use 1.8.7
<shevy>
why do you also use "r+:UTF-8"
<tolland>
erm, some article said about specifying encodings might help
<Mon_Ouie>
RUby 1.8.7 doesn't know about encodings
<tolland>
its not giving an error
<DrAwkward>
Hi, I'm having a slight problem with Benchmark, it doesn't want to print the labels for each line
<DrAwkward>
Using Ruby 1.9.3
OpenJuicer has joined #ruby
<Mon_Ouie>
And unless you have a reason, use #seek, not #sysseek
<Veejay>
But I still don't see lable in the report
<Veejay>
labels sorry
<tolland>
ok i see
mikespokefire has joined #ruby
albemuth has joined #ruby
<tolland>
shevy: ok, so you asked for this? whats the difference between the sysseek and seek functions then? (obvioously i could google, but that might be dangerous.... ;-)
sohocoke has joined #ruby
<shevy>
I did not mention sysseek or seek
<shevy>
you have to ask Mon_Ouie for that because he mentioned it
TaTonka has joined #ruby
gid0 has joined #ruby
Karmaon has joined #ruby
<tolland>
shevy: its ok, i will google. thnx. seek is doing as I wish, I will go and read ruby IO
<tolland>
Mon_Ouie: thanks that was it.
tolland has quit [#ruby]
nfluxx has joined #ruby
j3r0m3 has joined #ruby
Gesh has joined #ruby
sohocoke has joined #ruby
omry_ has joined #ruby
DrShoggoth has joined #ruby
swarley has joined #ruby
davorb_ has joined #ruby
badabim has joined #ruby
kevinbond has joined #ruby
emocakes has joined #ruby
CacheMoney has joined #ruby
CheeToS has joined #ruby
burns180 has joined #ruby
looopy has joined #ruby
Narcissus has joined #ruby
Narcissus has joined #ruby
deryldoucette has joined #ruby
Pheen has joined #ruby
Tearan has joined #ruby
pxjorge has joined #ruby
libertyp1ime has joined #ruby
maletor has joined #ruby
davidpk has joined #ruby
symb0l has joined #ruby
artOfWar has joined #ruby
hasrb has joined #ruby
neohunter has joined #ruby
tewecske has joined #ruby
<xeno_>
in haml, how do you explicitely set a checkbox to unchecked?
<xeno_>
and at the same time manage to have more arguments...
<xeno_>
tried everything from having false,nil as the second argument, to setting :checked => nil and false, :enabled to false and so on...
<pastjean>
hi there , im trying to compile ruby directly on my arm board and get an error from the configure script i downloaded the stable src from the site :: here is the error : "configure: error: could not determine MAJOR number from version.h"
Y_Ichiro has joined #ruby
Y_Ichiro has joined #ruby
burns180 has joined #ruby
<pastjean>
when setting MAJOR MINOR and TEENY in build script it blocks further saying "configure: error: cannot run /bin/bash tool/config.sub"
<pastjean>
do you have any idea on how to help me ?
<Guest13984>
Hi all, could someone kindly help me with this strange problem? I had peviously working code that used the following line: p12= OpenSSL::PKCS12.new(File.read('path_to_p12file'), 'password') it suddently stopped working with seemingly no changes to explain it, but now it's saying it needs 4 parameters instead of 2? any insight on this
<Guest13984>
I'm having trouble finding sufficient documentation for what the parameters should be
Seisatsu has joined #ruby
<gen0cide_>
Probably look at the source code
<gen0cide_>
sec
<Guest13984>
it's somewhere in the 'net/https/ hierarchy, cause that's what I had to require to use it
<Guest13984>
it's almost like the require 'net/https' changed, but that shouldn't happen, right? it should be local?
<Guest13984>
cause it just threw up an error in the middle of running some trials with no code changes
fbernier has joined #ruby
<Guest13984>
1.9.2 shows the 4 as well
<gen0cide_>
are you requiring openssl?
<Guest13984>
but I want to know is what changed? it was literally just working, and the order was opposite too, with file, password, as opposed to pass, file as the API suggets
<Guest13984>
yes
<gen0cide_>
the api suggests key then pass
<Guest13984>
also unless I'm totally confused, I was using it to get a key and a cert out of a p12
<Guest13984>
this is saying I need a key and cert as input?
<gen0cide_>
you're looking at the create method
<gen0cide_>
look at the new method
hubub_ has joined #ruby
<gen0cide_>
require 'openssl'
<JonnieCache|home>
AAAARGH
<Guest13984>
yeh I just noticed that
<JonnieCache|home>
ALWAYS READ THE DOCUMENTATION TWICE BOYS AND GIRLS
<Guest13984>
new requires just 2 params though?
<Guest13984>
so that doesn't resolve my question
<gen0cide_>
yes
<Guest13984>
why is it erring in irb saying it wants 4?
hubub_ has joined #ruby
gid0 has joined #ruby
phantomfakeBNC has joined #ruby
elliot98 has joined #ruby
<gen0cide_>
I'm not quite sure
elliot98 has joined #ruby
<elliot98>
when starting irb, is it possible to automatically execute some statements, say, from a text file
<apeiros_>
elliot98: load(path)
<apeiros_>
also irb -rsomepath
<gen0cide_>
^
<elliot98>
apeiros_: but the variables don't seem to persist
<apeiros_>
elliot98: of course, they aren't called *local* variables for begin global…
<apeiros_>
*beign
<apeiros_>
gawd… being
<apeiros_>
use the proper kind of variables if you want to use them across the file
<elliot98>
apeiros_: so load makes them local variables
<apeiros_>
elliot98: eh?
<apeiros_>
local variables are local variables by syntax
<fowl>
(:
<elliot98>
apeiros_: but want to just automate executing commands in irb
rburton- has joined #ruby
<apeiros_>
you remember, those things that start with _ or [a-z]
<apeiros_>
elliot98: "I want to just…" doesn't change how ruby works…
<apeiros_>
again, use the proper kind of variables
<apeiros_>
i.e. constants or globals (globals are instafail, though)
<elliot98>
apeiros_: so there is no way just to pipe into irb some commands before loading the command line?
<apeiros_>
elliot98: yes, there is, as said, require or load
rburton-_ has joined #ruby
<apeiros_>
but commands != variables
<apeiros_>
and lvars != whatever other vars…
<elliot98>
apeiros_: but load is a bit different, say, if one is to run age = 5 in the irb , then puts age would print "5"
<apeiros_>
load allows loading the same file multiple times
<apeiros_>
require doesn't
<apeiros_>
load doesn't handle anything but ruby
<apeiros_>
load requires the suffix to be stated
phantomfakeBNC has joined #ruby
<apeiros_>
end of differences (afaik)
<elliot98>
apeiros_: but if will load a file that contains "age = 5" , then puts age in the irb would responds with no variable error
igaiga has joined #ruby
<fowl>
apeiros_: what else does require handle if not ruby
<gen0cide_>
I suggest you do learn about variable scopes tho
<gen0cide_>
apeiros_ is absolutely right
albemuth has joined #ruby
<gen0cide_>
it's imperative that you learn about variable scope if you plan on doing any programming - ruby or not
hyper_ch has joined #ruby
<elliot98>
gen0cide_: variable scope is one thing, automating a few commands in irb is another
<hyper_ch>
hi there, I try to correct RVM somehow... for some reasons I tries to link to another user's account and I can't find out why
<elliot98>
gen0cide_: what is the scope for variables on the irb command line?
<gen0cide_>
scope is scope whether inside irb or a script
<elliot98>
yes, but a variable in irb can't necessarily be accessed in a script and vice versa
<gen0cide_>
yes because of scope
<elliot98>
gen0cide_: ok, so running a script with load is not the same and running the command from the irb CLI
<elliot98>
gen0cide_: because it's a different scope
<gen0cide_>
any script you "load" into IRB
<gen0cide_>
if you want to access a variable
<gen0cide_>
from within that script
<gen0cide_>
you'll have to make it a global
<gen0cide_>
think of the script as class
<elliot98>
gen0cide_: so the question is, how do you automate commands so the scope stays within the IRB CLI scope
<gen0cide_>
use ruby-debug
<elliot98>
gen0cide_: that's what I needed
<gen0cide_>
or scope your variables locally
<gen0cide_>
**globally
<elliot98>
using $
<gen0cide_>
yes
<gen0cide_>
but thats poor practice
looopy has joined #ruby
<gen0cide_>
and when you do debugger with ruby-debug
<gen0cide_>
you're dropped within the scope of the current execution block
<gen0cide_>
remember that
<zandt>
I bought a few books to read while I have some free time off from school. no programming experience, but I will consider this free time a success if I learn what variable scope is :)
<elliot98>
gen0cide_: ok
<elliot98>
gen0cide_: so it's not really possible to automate statements inside the IRB CLI scope
<elliot98>
gen0cide_: unless you'd pipe things
<gen0cide_>
how about instead of trying to access variables
<gen0cide_>
write your script in proper OO form
<gen0cide_>
that will make your life much easier
burns180_ has joined #ruby
<elliot98>
gen0cide_: eventually, but part of the program is using some odd XML-like parsing, some for the time being, want to play around in the irb before actually pulling everything together into a class
CheeToS has joined #ruby
<gen0cide_>
you have an object representing the parsed XML - it might be a hash or something similar
<gen0cide_>
inside your script
<gen0cide_>
with ruby debug
<gen0cide_>
you'll have a line
<elliot98>
ruby-debug seems to be the way to go
hyper_ch has quit ["Konversation terminated!"]
<gen0cide_>
parser = XMLParser.new("filename")
caiges has joined #ruby
<gen0cide_>
parsed_object = parser.parse!
<gen0cide_>
then do debugger
<gen0cide_>
you'll be able to access parsed_object from within irb then
<avalarion>
Hi there, I don't know how to get my MySQL Object, is there a dirty way to fire sql commands without or a way to get is as singleton?
chimkan has joined #ruby
undersc0re has joined #ruby
k_89_ has joined #ruby
DrShoggoth has joined #ruby
technel has joined #ruby
adeponte has joined #ruby
keymone_ has joined #ruby
dbgster has joined #ruby
nobitanobi has joined #ruby
<nobitanobi>
Hi. I'm getting URI::InvalidURIError when trying to open a URI like this: https://chart.googleapis.com/chart?cht=lc&chd=s:cEAELFJHHHKUju9uuXUc&chco=76A4FB&chls=2.0&chs=220x125&chxt=x,y&chxr=1,0,4&chxl=3:|Jan|Feb|Mar&chxs=2,0000dd,13,-1,t,FF0000&chxp=2,10,35,95&chxtc=1,5,15
<nobitanobi>
anyone can point me what can be going wrong?
manizzle has joined #ruby
qurve has joined #ruby
igotnolegs has joined #ruby
rdesfo has joined #ruby
looopy has joined #ruby
mdw has joined #ruby
noyb has joined #ruby
baroquebobcat has joined #ruby
davidpk has joined #ruby
nobitanobi has joined #ruby
burns180 has joined #ruby
drake10 has joined #ruby
Seisatsu has joined #ruby
<technel>
How would I find a Date object for the most recent Monday in Ruby?
apeiros_ has joined #ruby
apeiros_ has joined #ruby
nobitanobi has joined #ruby
nobitanobi has joined #ruby
liluo has joined #ruby
jacktrik has joined #ruby
nobitanobi has joined #ruby
drbawb has joined #ruby
akem has joined #ruby
M- has joined #ruby
pgebhard has joined #ruby
johndbritton has joined #ruby
CID- has joined #ruby
Enchilada has joined #ruby
ph^ has joined #ruby
<Enchilada>
Ruby seems like a great "tool" language. I mean, if you have some idea that you want to mockup quickly. Instead of having to compile, you just quickly write a simple script, and just run it, because ruby is already there.
<Enchilada>
Am I misunderstanding the purpose of Ruby?
<Enchilada>
Maybe this is the core diff between compiled and scripting langs?
tmba has joined #ruby
CID- has quit [#ruby]
_|christian|_ has joined #ruby
burns180_ has joined #ruby
coofamani has joined #ruby
<coofamani>
Are the tutorials on the Ruby documentation page the best place to start? I know intermediate Python and PHP and none Ruby.
Drewch has joined #ruby
pastjean has joined #ruby
Jay_Levitt has joined #ruby
<Tasser>
Enchilada, it's a programming language like any other
<Tasser>
coofamani, rubykoans are good exercises
<Enchilada>
hmm ok
<coofamani>
Tasser: thanks
<Tasser>
coofamani, for a book, there's the pragprog, learning how to program, and some others
emocakes has joined #ruby
<Tasser>
Enchilada, it's great for writing glue code, but a dynamic language can only grow so big
<Enchilada>
Tasser: what do you mean grow so big?
<Tasser>
Enchilada, speed and static typing helps you in a big project... but after all, it's the people, not the programming language
shevy2 has joined #ruby
<Enchilada>
ok..
<Tasser>
except you program in malbolg
<Tasser>
ehh malbolge
<Enchilada>
ok… lol
<Enchilada>
didn't even know about that one until now
<Enchilada>
hehe, computers can be coded to code in malbolge
<Enchilada>
maybe this is the beginning of skynet
<Enchilada>
so the machines can sustain themselves
* Enchilada
stops ranting.
havenn has joined #ruby
vmatiyko has quit [#ruby]
c0rn has joined #ruby
<jgrevich>
can you only override a method by redefining it? I can't seem to get the same functionality when using include ModuleName.
UForgotten has joined #ruby
<Tasser>
jgrevich, why not?
<havenn>
jgrevich: What are you trying to do? Remove a method, add one, or what?
<havenn>
jgrevich: Might be that you need to 'extend' rather than 'include'?
<jgrevich>
I can get the functionality I want when I redefine msg_att method in the same file
<gytis_z>
hi, total newbie here, so don't hate too much but can someone explain why does dict = Hash.new([]) ; words.each { |word| dict[<some code>] << word } produce an empty hash? I have no trouble counting stuff like this (using ints instead of arrays) but can't get this to work
<jgrevich>
havenn: I thought extend is only for class methods?
odinswand has joined #ruby
<jgrevich>
lib/ruby/1.9.1/net/imap.rb:2159 is the location of the method i'm trying to override