<planck>
Hey. I'm trying to figure out how to run ARGV from the terminal. Do I need some kind of special interpreter? Because it doesn't seem to work.
<jhass>
"run ARGV"?
<pipework>
What does "run ARGV" mean?
<jhass>
what does that mean?
<pipework>
jhass: lul
tockitj has joined #ruby-lang
<jhass>
^5
<planck>
Haha, oh sorry. :P
<pipework>
^6 with a +1 for being jhass so consistently.
<planck>
Ill try to explain better. Wait
<yorickpeterse>
If you mean you want to set them, you'll have to run your script like `ruby some_script.rb arg1 arg2 arg3`
rikkipitt has joined #ruby-lang
<planck>
so i've got a script that looks something like this:
<planck>
filename = ARGV.first
rikkipitt has quit [Remote host closed the connection]
<planck>
txt = open(filename)
rikkipitt has joined #ruby-lang
<pipework>
planck: gist your script
<planck>
that will probably work better. thanks
<pipework>
And, unless you can explain it on one line in IRC, add another 'file' to the gist with an explanation. Feel free to add code comments to specific bits.
<jhass>
then what yorickpeterse said, you may also be interested in ARGF, and always pass a block to open
<planck>
so. my problem is basically this. i run the script from the terminal. but nothing happens.
<pipework>
planck: So, is there something wrong with the filename local, or what part are you having trouble with? There are things you should change, but I'd like to hold those until you explain what's not working as you expect.
fumduq has quit [Ping timeout: 252 seconds]
<pipework>
No puts gets written? How are you running this script?
duderonomy has quit [Read error: Connection reset by peer]
<planck>
ruby filename.rb
fumduq has joined #ruby-lang
<pipework>
planck: And you never see "Here's your file filename.rb"?
<pipework>
I should check to make sure he's calling ARGV right, I always forget if it's a global ornot.
<jhass>
it should throw on passing nil to open
<pipework>
Ah it's a method.
arBmind has quit [Read error: Connection reset by peer]
<jhass>
>> method(:ARGV)
<eval-in>
jhass => undefined method `ARGV' for class `Object' (NameError) ... (https://eval.in/309958)
<jhass>
nope
stamina has joined #ruby-lang
<jhass>
it's a constant with an object assigned that pretends to be an array
rikkipitt has quit [Remote host closed the connection]
workmad3 has joined #ruby-lang
<jhass>
planck: please put the following into a file:
<jhass>
p ARGV
<planck>
jhass: alright
<jhass>
run it with, ruby foo.rb
<jhass>
then with ruby foo.rb a
<jhass>
then with ruby foo.rb a b
c0m0 has quit [Ping timeout: 244 seconds]
<jhass>
then with ruby foo.rb "a b"
<jhass>
compare the outputs
<workmad3>
jhass: heh :) you could have suggested 'ruby -e "p ARGV" a b' rather than create a file ;)
<jhass>
workmad3: yeah, I think that makes it less clear though
<planck>
jhass: so this is what i get: can't covert nil into String
<jhass>
yeah
<jhass>
did you do what I said?
<planck>
jhass: im on it. just booting the computer. im on my phone atm :P
duderonomy has joined #ruby-lang
duderonomy has quit [Max SendQ exceeded]
<planck>
jhass: alright. so i get the same result if i run with the flags a and a b "initialize: no such file or directory. from foo.rb:2:in open and main
<jhass>
I'm not saying you should run your script with a, a b
<jhass>
just a script containing "p ARGV"
<jhass>
so you can see how it works
<planck>
jhass: oh :D
stamina has quit [Quit: WeeChat 1.1.1]
planck has quit [Quit: Page closed]
<pipework>
workmad3: That works this time, but there are things in ruby that won't work with the -e line very whale.
<jds>
Am I right in thinking that the number of live objects in GC.stat is :total_allocated_objects - :total_freed_objects ?
<workmad3>
pipework: right... but we're not talking about those hypotheticals, we're talking about the concrete case where it does work this time :P
<pipework>
Hypotheticals? __FILE__ and the like are hypothetical? binding too?
<workmad3>
pipework: in this situation, they're hypothetical
<pipework>
I'd at least mention the caveat eagerly.
<pipework>
However, I agree with jhass on keeping it file-oriented so no translation is necessary. If they're having trouble with ARGV, maybe they'll also have trouble with translating the one-liner.
<workmad3>
pipework: I've also not had enough coffee yet, so I'm stubborn, argumentative and defensive :P
c0m0 has joined #ruby-lang
<workmad3>
or rather, more so than usual on those attributes :)
<pipework>
workmad3: Good morning, darling.
GBrawl has joined #ruby-lang
ur5us has quit [Remote host closed the connection]
planck has joined #ruby-lang
<planck>
jhass: nothing happens at all. and i tried something else. like assigning arguments to ARGV... like first, second, third = ARGV and tried to print it out. but its just blank
<mikecmpbll>
that's actually how activesupport's `descendants` method works :p
<ruby-lang899>
Hello, I was recently trying my hand at testing in rails and got a little confused with how mocha works. As in - when I say - object.expects(:someModule).returns(someResult), does it execute 'someModule' or does it check whether it has been called?
<yorickpeterse>
mikecmpbll: doesn't it keep track of them in an array?
<BFlorin>
hei guys, i am trying to figure it how to fix this error, []`: no implicit conversion of Symbol into Integer (TypeError) fix
<BFlorin>
mikecmpbll: basically, i am trying to download the files from each of the court, and to output a csv file for each court
<BFlorin>
mikecmpbll: and i get that error at line 49
ruby-lang899 has quit [Ping timeout: 246 seconds]
<mikecmpbll>
BFlorin: ok, so parte is an array, why are you trying to access it like it's a hash?
<BFlorin>
mikecmpbll: because i don`t know how to acces it as a array :)
agarie has joined #ruby-lang
<mikecmpbll>
with an index of the item you want from the array
<mikecmpbll>
['a','b','c'][2] == 'c'
symm- has quit [Ping timeout: 264 seconds]
johnchalekson has quit [Read error: Connection reset by peer]
lytol has joined #ruby-lang
johnchalekson has joined #ruby-lang
johnchalekson has quit [Max SendQ exceeded]
johnchalekson has joined #ruby-lang
<BFlorin>
mikecmpbll: i don`t where to modify this, i will search for the documentation, hopefully i will find it
<BFlorin>
mikecmpbll: i tried removing the |parte| and putting ['nume','calitate_Parte'][2] == 'nume'
lytol has quit [Ping timeout: 264 seconds]
<mikecmpbll>
:/ tbh i'm not at all sure what you're trying to do
havenwood has joined #ruby-lang
<ljarvis>
dat code
<mikecmpbll>
BFlorin: you have some data being returned from your SOAP thing in `dosare` -- how you fix your error depends entirely on the structure of this and what you want to do with it
<mikecmpbll>
neither of which have you made clear :)
<mikecmpbll>
BFlorin: the data isn't that important, it's the structure of the response object.
adude has quit [Ping timeout: 256 seconds]
<mikecmpbll>
from the code I can infer that dosar[:parti][:dosar_parte] is an array of arrays, what do the inner arrays (`parte`) contain and what do you want to do with the contents?
<mikecmpbll>
actually, it could be an array of strings. i didn't consider that.
brushbox has joined #ruby-lang
caseydriscoll has quit [Remote host closed the connection]
<mikecmpbll>
so you don't want [:dosar_parte].each..
<mikecmpbll>
just do: dosarParteNume += dosar[:parti][:dosar_parte][:nume] + "#"
bruno- has joined #ruby-lang
Contigi777 has quit [Quit: Leaving]
<mikecmpbll>
unless with this API dosar[:parti][:dosar_parte] is sometimes a collection, and sometimes not? (not uncommon with SOAP interfaces x_x)
Miphix has quit [Quit: Leaving]
<BFlorin>
the api is badly documented, because they don`t want people having access to the data, i think, so they are faking it, they say that they allow people to play with the data, but is really hard to get the data
<mikecmpbll>
:)
<mikecmpbll>
if it can vary between collection and not, you can use something like [dosar[:parti][:dosar_parte]].flatten.each do |parte|
jgpawletko has joined #ruby-lang
bruno- has quit [Ping timeout: 264 seconds]
hahuang65 has joined #ruby-lang
arBmind1 has quit [Quit: Leaving.]
arBmind has joined #ruby-lang
Miphix has joined #ruby-lang
<BFlorin>
mikecmpbll: now is different, it work for 6 files 111/44/2004 112/44/2004 115/44/2004 113/44/2004 114/44/2004 117/44/2004 116/44/2004 F:/Expert Forum/ruby client/ruby client/vivi_ruby.rb:50:in `[]': no implicit con version of Symbol into Integer (TypeError)
<mikecmpbll>
hehe. so looks like it does vary
hahuang65 has quit [Ping timeout: 248 seconds]
<mikecmpbll>
BFlorin: normalize it as always an array like i put above
<mikecmpbll>
also, << many factors faster than += for building strings.
<BFlorin>
to parse it somehow that will work
<mikecmpbll>
BFlorin: sure, use the code i showed.
<BFlorin>
mikecmpbll: Now it did almost 200 files, before showing this 214/44/2004 223/44/2004 F:/Expert Forum/ruby client/ruby client/vivi_ruby.rb:48:in `block (3 levels) in <main>': undefined method `[]' for nil:NilClass (NoMethodError)
kfpratt has joined #ruby-lang
<mikecmpbll>
can you update the gist with your current code? i'm not sure which is line 48 anymore.
byprdct has joined #ruby-lang
byprdct has quit [Max SendQ exceeded]
<BFlorin>
mikecmpbll: i have updated it, 48 is this [dosar[:parti][:dosar_parte]].flatten.each do |parte|
mattyohe has joined #ruby-lang
<mikecmpbll>
ah okay. so dosar[:parti] must be nil in this instance.
<mikecmpbll>
you will have to check for that.
<mikecmpbll>
if dosar[:parti] ....
dm78 has joined #ruby-lang
sankaber has quit [Read error: Connection reset by peer]
mvdb has quit [Quit: Leaving]
sankaber has joined #ruby-lang
charliesome has quit [Quit: zzz]
timanema has joined #ruby-lang
MagicHat has joined #ruby-lang
bruno- has joined #ruby-lang
jwaldrip has joined #ruby-lang
<BFlorin>
mikecmpbll: i am guessing that if dosarParteNume != nil will not work
<mikecmpbll>
BFlorin: nope it's not dosarParteNume which is nil :)
cpt_yossarian has quit [Quit: And then he took off.]
cpt_yossarian has joined #ruby-lang
<BFlorin>
mikecmpbll: Yeeey, is working!!!!!
<mikecmpbll>
BFlorin: :))
brushbox has quit [Quit: Leaving.]
<BFlorin>
mikecmpbll: thank you very much!!! Now i can start to modify for the rest of the data that i need and i can do some vital statistics about the justice system in my country :D
lapide_viridi has quit [Quit: Leaving]
agarie has quit [Remote host closed the connection]
<mikecmpbll>
BFlorin: good work, happy data gathering.
MagicHat has quit [Remote host closed the connection]
cpt_yossarian has quit [Quit: And then he took off.]
whippythellama has joined #ruby-lang
davispuh has joined #ruby-lang
caseydriscoll has joined #ruby-lang
ldnunes has quit [Quit: Leaving]
Mellett68 has quit [Remote host closed the connection]
Mellett68 has joined #ruby-lang
chouhoulis has joined #ruby-lang
<BFlorin>
mikecmpbll: i tryied to extrapolate to the other fields that i want, but i got this 111/44/2004 F:/Expert Forum/ruby client/ruby client/vivi_ruby.rb:73:in `block (4 levels) in <main>': undefined method `+' for nil:NilClass (NoMethodError)
lytol has joined #ruby-lang
archie has quit [Ping timeout: 252 seconds]
<mikecmpbll>
BFlorin: okay, so what do you suppose that means?
<BFlorin>
most probably something related to my code, he says that i did not provided him with a way to catch a error
riotjones has quit [Remote host closed the connection]
<BFlorin>
i think
n3b- has joined #ruby-lang
slawrence00 has joined #ruby-lang
lytol has quit [Ping timeout: 244 seconds]
<BFlorin>
mikecmpbll: but if it worked for one , then i just copy pasted and changed other setting, so it`s more probably with the way the data is coming from the server.... https://gist.github.com/baditaflorin/eedac2a2c5fcbb82a865/
agarie has joined #ruby-lang
<mikecmpbll>
BFlorin: well, the error message "undefined method `+' for nil:NilClass (NoMethodError)" is literally telling you that you're trying to call `+' on nil
<mikecmpbll>
you're using + twice on that line: dosarsedintasolutiesumar += sedinta[:solutie_sumar] + "#"
<mikecmpbll>
on dosarsedintasolutiesumar, and on sedinta[:solutie_sumar]. you're defining dosarsedintasolutiesumar as "" on line 70 so that's definitely not nil, so it must be sedinta[:solutie_sumar] that is nil.
<BFlorin>
mikecmpbll: but this is the same as in like 50, 57 and 65
<BFlorin>
:)
<mikecmpbll>
yep, but in the data sedinta[:solutie_sumar] is nil
<BFlorin>
i downloaded 2 other courtroom files, and it worked good, and at this one, after 10034 files, probaby bacause it`s returning another type of data, is not worming
lytol has quit [Remote host closed the connection]
MagicHat has joined #ruby-lang
cpt_yossarian has joined #ruby-lang
LMity has quit [Ping timeout: 246 seconds]
ascarter has joined #ruby-lang
jwaldrip has joined #ruby-lang
cartothemax has quit [Remote host closed the connection]
cartothemax has joined #ruby-lang
malconis has quit [Ping timeout: 245 seconds]
ascarter has quit [Client Quit]
malconis has joined #ruby-lang
adude has quit [Ping timeout: 252 seconds]
b_hoffman has joined #ruby-lang
roamingdog has joined #ruby-lang
godzillaenlacasa has joined #ruby-lang
<godzillaenlacasa>
is there a built in ruby module to grep in real time commands put in terminal window? I.e., I'm only wanting to know if the line XYZ shows up in my terminal window while running my ruby script?
arBmind has joined #ruby-lang
<godzillaenlacasa>
...and 'commands' is probably the wrong word... my script outputs results to the terminal window and I'd like to grep in real time the results... specifically looking for a match
<mikecmpbll>
BFlorin: well ... it appears there are multiple dosar[:parti] in this file.
<mikecmpbll>
BFlorin: you have to decide how you want to process multiple of these.
<jhass>
godzillaenlacasa: if your script is outputting stuff, why don't you just do whatever you want to do in the same condition that triggers that output?
nertzy has quit [Quit: This computer has gone to sleep]
<jhass>
that sounds like you have a design problem in your program tbh
<godzillaenlacasa>
jhass yes, that makes sense...
<mikecmpbll>
or just copypaste the output into an editor and search it ..
<BFlorin>
mikecmpbll: the same as bifore, to be added in the same field , separated with '#'
cartothemax has quit [Remote host closed the connection]
<BFlorin>
mikecmpbll: if is posible
cartothemax2 has joined #ruby-lang
<mikecmpbll>
but dosar[:parti] is the parent node
yfeldblum has joined #ruby-lang
Iskarlar has joined #ruby-lang
cornerma1 has joined #ruby-lang
<godzillaenlacasa>
on another note... my same script runs but requires user input in the terminal window "space_bar \r". Is there a way to mimic this in the script itself?
<jhass>
you have a severe design issue here
<jhass>
you want to run your script non-interactive but mixed the interactive code into the logic
<jhass>
now you try to automate the interactive part
<jhass>
that's doing it the wrong way around
baweaver has joined #ruby-lang
<jhass>
write the logic in a way that requires no interaction, then write an interactive interface to that
roamingdog has quit [Remote host closed the connection]
momomomomo has quit [Ping timeout: 264 seconds]
<BFlorin>
mikecmpbll: then a new node when it will encounter strage anomalies like this
<BFlorin>
a new row
cornerman has quit [Ping timeout: 248 seconds]
cornerma1 is now known as cornerman
MXfive has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<mikecmpbll>
as long as it works though ey, refactor after ;)
MagicHat has quit [Remote host closed the connection]
joaomdmoura has quit [Remote host closed the connection]
jgpawletko has quit [Quit: jgpawletko]
ruby-lang has quit [Ping timeout: 265 seconds]
MagicHat has joined #ruby-lang
cengizIO has joined #ruby-lang
roamingdog has joined #ruby-lang
michaeldeol has joined #ruby-lang
ta has quit [Quit: Leaving...]
<godzillaenlacasa>
Anyone know where i can go to get the cipher algorithms supported for OpenSSL::Cipher ? , IE. AES-128-CBC, AES-256-CBC, EXP, DES,....?
<Zen-Zen>
Not sure why I cannot access my instance method
baweaver_ has quit [Remote host closed the connection]
<jhass>
what's the error?
ruby-lang has joined #ruby-lang
<Zen-Zen>
undefined method from the area I labelled problem
<jhass>
ah, I see
<jhass>
you need to call instance methods on the object
<Zen-Zen>
could you give me an example so I am clear...
<jhass>
"foo".upcase # Here we call the instance method upcase of the String classs on the object "foo" (an instance of String)
<Zen-Zen>
so the .instance method is no differnt than the class instance method.
joaomdmoura has joined #ruby-lang
<jhass>
well, you call the class method on a different object than the instance method, but it's the same mechanism, yes
<Zen-Zen>
beefTaco.servedItem ike this?
<jhass>
what kind of object is beefTaco?
<Zen-Zen>
It is from the MenuItem class same as the servedItem method.
<Zen-Zen>
3 arguments - type, choiceMeat, price
<jhass>
well, I don't follow the second part, but yes, it's an instance of MenuItem
Boondox has quit []
<jhass>
now where is servedItem defined?
<jhass>
it's an instance method of which class?
<Zen-Zen>
menuItem
<jhass>
not according to your gist
<Zen-Zen>
sry you are right... it is in the ChipoltleRestaurant class
<jhass>
so, what variable contains an instance of that class?
<Zen-Zen>
beefTaco.Menuitem.servedItem ??
<jhass>
that's a chained method call on the beefTaco variable
<jhass>
I asked what variable is an instance of ChipoltleRestaurant
<Zen-Zen>
beefTaco.ChipotleRestaurant.servedItem is what I meant to type above.
<jhass>
same answer
<Zen-Zen>
cr
<jhass>
right!
<Zen-Zen>
cr is the variable of Chiotle Restaurant
<jhass>
so, cr is an instance of CipotleRestaurant, ChipotleRestaurant has the instance method servedItem that you want to call
baweaver has joined #ruby-lang
<jhass>
how would that call look like?
<Zen-Zen>
beefTaco.cr.servedItem
<jhass>
no
<jhass>
do you even try to understand or are you just guessing?
<Zen-Zen>
I am trying to follow along, I appreciate your trying to help.
joaomdmoura has quit [Remote host closed the connection]
AlexAltea has joined #ruby-lang
<Zen-Zen>
Lemme see what I can come up with and I will check back. thx jhass!
djbkd has quit [Remote host closed the connection]
roamingdog has joined #ruby-lang
nertzy has joined #ruby-lang
hotpancakes has quit []
troyleak has joined #ruby-lang
SylarRuby has joined #ruby-lang
wallerdev has joined #ruby-lang
<godzillaenlacasa>
is it possible to pass a command line argument into a system() call in an rb script?
<jhass>
yes
<jhass>
the docs for system have plenty of examples for all the invocations of it
b_hoffman has quit [Quit: b_hoffman]
<godzillaenlacasa>
jhass are you refering to somewhere other than ruby-doc.org? They weren't very telling on there
<jhass>
no, I'm referring on that
Mark-6ma has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
EnduranceMan has quit []
<jhass>
just checked again, they list the allowed forms just fine
b_hoffman has joined #ruby-lang
aeze has joined #ruby-lang
joaomdmoura has joined #ruby-lang
b_hoffman has quit [Client Quit]
b_hoffman has joined #ruby-lang
begal-sop__ has quit [Remote host closed the connection]
begal-sop has joined #ruby-lang
nertzy has quit [Quit: This computer has gone to sleep]
<Zen-Zen>
jhass I just wanted to say thx for your patience... item1 = cr.servedItem(beefTaco) think I got it, still need to digest info a bit - but always appreciate the assist!
<jhass>
looks good, yw
pragmatism has joined #ruby-lang
<BFlorin>
mikecmpbll: sorry for the late reply, i was trying to figure out something with openrefine, i am testing now, thanks for all your help again
<jhass>
now look at the docs for system again with that information
<jhass>
which form could fit?
<godzillaenlacasa>
s = system "openssl", "s_client", "-connect", hos
<jhass>
looks good, what's the problem? (besides blocking endlessly because s_client reads from standard input)
<BFlorin>
mikecmpbll: that is strange, at 49 , i get the same error
<BFlorin>
mikecmpbll: if dosar[:parti]
<BFlorin>
mikecmpbll: F:/Expert Forum/ruby client/ruby client/vivi_ruby.rb:49:in `[]': no implicit con version of Symbol into Integer (TypeError)
<mikecmpbll>
BFlorin: er ...
<mikecmpbll>
BFlorin: gist current code :)
dellavg_ has quit [Ping timeout: 264 seconds]
aeze has quit [Quit: aeze]
ruby-lang has left #ruby-lang [#ruby-lang]
joaomdmoura has quit [Remote host closed the connection]
Iskarlar has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<dudemanbro>
I'm a bit new to this, but is there a way to turn off notificaionts for people entering/leaving? I'm trying to follow along with some of the discussion and well, maybe I'm just too OCD
joaomdmoura has joined #ruby-lang
<mikecmpbll>
dudemanbro: what client do you use?
<dudemanbro>
good old google chrome at this point
baweaver has quit [Remote host closed the connection]
hollywoodthrill has joined #ruby-lang
momomomomo has joined #ruby-lang
Bertg has joined #ruby-lang
RobertBirnie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]