<rhizmoe>
is there a way to mark a variable as read-only?
<RegEchse>
WillMarshall: i neither get your terminology (kinda weird) nor your question.
<RegEchse>
rhizmoe: do you really mean _variable_? That would be what constants are for.
apeiros_ has joined #ruby-lang
Faris2 has joined #ruby-lang
<drbrain>
not even constants are read-only in ruby
<RegEchse>
drbrain: But that's what they're for. :)
<RegEchse>
and he only asked a way for "marking". constants are "marked" as read-only. (what in fact doesn't bother ruby to reassign constants :/)
<injekt>
it bothers ruby, ruby shouts at you
<injekt>
but then it's all like lol na bro go ahead
<RegEchse>
It's a fact i never got to look up: why does ruby have mutable _const_ants? xD
havenn has joined #ruby-lang
<injekt>
ruby doesn't 'enforce' anything, it just indicates how you should use something sometimes
<injekt>
like ruby doesn't have true private/protected methods, for example
<injekt>
but we have the keywords because they're 'supposed' to be private/protected
<robbrit>
rhizmoe: put a capital as the first letter of the variable
<injekt>
dont just do that, though
io_syl has joined #ruby-lang
<robbrit>
rhizmoe: if you put the first letter as a capital then Ruby will warn you when you change it, that's the closest you can get to a "constant" in ruby
<injekt>
robbrit: you talk about it like it's not a 'Ruby constant' when you have it capitalized
robbrit has quit [#ruby-lang]
RedNifre has joined #ruby-lang
<RedNifre>
Hello!
<RedNifre>
I wrote a little class and I'd like to have myobject * 3 do something special (similiar to how "a"*3 results in "aaa"). How do I define how my own object reacts to *?
<injekt>
def *(arg)
<RedNifre>
I tried, somehow it didn't work. Guess I made a mistake somewhere else.
<RedNifre>
brb (debugging)
burns180 has joined #ruby-lang
leonL_ has joined #ruby-lang
twittard has joined #ruby-lang
<RedNifre>
"MyObject can't be coerced into Fixnum (TypeError)" what can I do about that? (The object encapsulates a number)
<RedNifre>
I want to use this to represent a distribution of things, but it should also work in equations as a number (having the value of the total)
<injekt>
RedNifre: and what's the problem?
<RedNifre>
rb:48:in `-': Amount can't be coerced into Fixnum (TypeError)
<RedNifre>
from midas.rb:48:in `-'
<RedNifre>
hmmm....
thone has joined #ruby-lang
<RedNifre>
at that point in the code @total should be somestring.to_i
<RedNifre>
So what does it mean that it can't be coerced into fixnum? (I'm very new to ruby)
<injekt>
this can't be all of the relevant code. You're trying to coerce your class into a fixnum which I can't see happening in that pastie
<RedNifre>
Hm, no, the error is about coercing the number @total into a fixnum I think.
<drbrain>
RedNifre: 1 + other_object uses the coerce protocol to convert other_object into a fixnum
<drbrain>
so that addition may take place
<RedNifre>
The error happens here:
<drbrain>
no, it's about coercing Amount into a fixnum, not the value
<RedNifre>
def -(number)
<RedNifre>
@total - number
<RedNifre>
end
<RedNifre>
In the code I pasted.
<drbrain>
"Amount can't be coerced into Fixnum"
achiu1 has joined #ruby-lang
<injekt>
^
<RedNifre>
okay, but why does it happen at that... oh, right!
<RedNifre>
number itself can be an Amount-Object...
<injekt>
then there's the problem
<RedNifre>
So what can I do if I want to write amount1 - amount2 ?
<injekt>
@total - number.to_i
<RedNifre>
of course! :)
<RedNifre>
...plus a to_i method for Amount that returns @total
<RedNifre>
Thank you very much!
<petercooper>
yeah, that bit is pretty critical here :)
<RedNifre>
Heh, ruby is really nice. In Java it would have ended in Amount.add(Amount.sub(5)) ...
muzone has joined #ruby-lang
<petercooper>
Don't worry, after several years of Ruby you might start to think.. hmm, being less implicit and magical and using more method calls is a great idea! And the cycle restarts ;-)
<RedNifre>
:D
fayimora has joined #ruby-lang
lchi has joined #ruby-lang
<RedNifre>
Hm, what's the best practice for writing +-/* functions? I mean, if you can multiply strings I guess anything goes?
<injekt>
I avoid them
<injekt>
usually
<injekt>
:)
<drbrain>
RedNifre: I try to make them consistent
<drbrain>
with math
<injekt>
^ the only reason they should ever be used, imo
<drbrain>
… so the operations are appropriately commutative, etc.
<drbrain>
WillMarshall: if the superclass needs them, yes
<WillMarshall>
Will experiment. Cheers :)
<deryldoucette>
petercooper: dude, between you and Gregory, I got tons to learn! I'm not often vocal for people that do awesome things. Let me just say, thanks :)
<petercooper>
I saw your tweet, thanks man :)
<drbrain>
Object#initialize doesn't do anything, so you don't need to super to it
<deryldoucette>
welcome
plusk has joined #ruby-lang
<WillMarshall>
drbrain: Cheers :)
QoQOoO has joined #ruby-lang
Banistergalaxy has joined #ruby-lang
Jade has joined #ruby-lang
Jade has joined #ruby-lang
Joeysomo has joined #ruby-lang
Joeysomo has joined #ruby-lang
burns180 has joined #ruby-lang
apeiros has joined #ruby-lang
apeiros_ has joined #ruby-lang
apeiros has joined #ruby-lang
apeiros_ has joined #ruby-lang
apeiros_ has joined #ruby-lang
SkramX has joined #ruby-lang
apeiros_ has joined #ruby-lang
shtirlic has joined #ruby-lang
neoesque has joined #ruby-lang
theconartist has joined #ruby-lang
burns180_ has joined #ruby-lang
RedNifre2 has joined #ruby-lang
chessguy has joined #ruby-lang
apeiros_ has joined #ruby-lang
<WillMarshall>
Is there a "not implemented" exception in Ruby?
<drbrain>
NotImplementedError
<WillMarshall>
Thanks
esad has joined #ruby-lang
<esad>
If you're using modules purely as namespace - like for example I want to put all my resque jobs into a module - do you prefer singular or plural?
<esad>
Jobs::Crawl or Job::Crawl ? :)
burns180 has joined #ruby-lang
<drbrain>
singular
voker57 has joined #ruby-lang
voker57 has joined #ruby-lang
PatrixCR has joined #ruby-lang
leonL has joined #ruby-lang
igotnolegs has joined #ruby-lang
apeiros has joined #ruby-lang
chimkan__ has joined #ruby-lang
nofxx has joined #ruby-lang
acyed has joined #ruby-lang
Sailias has joined #ruby-lang
lchi has joined #ruby-lang
burns180_ has joined #ruby-lang
Phrogz has joined #ruby-lang
heftig has joined #ruby-lang
<WillMarshall>
How can I write to a classes @variables from outside that class?
Joeysomo has joined #ruby-lang
<shevy>
WillMarshall you must allow an accessor method. use a method
<shevy>
def foo(input)
<shevy>
@variables = input
<shevy>
end
<shevy>
or
<shevy>
def foo=(input)
<shevy>
@variables = input
<shevy>
end
<shevy>
and then...
<WillMarshall>
shevy: Cheers
<shevy>
your_object.foo = "some new value"
<shevy>
or
<shevy>
your_object.foo "some new value"
<shevy>
whatever you like more
<lianj>
or obj.instance_eval{ @foo = :feels_dirty }
<shevy>
usually the latter of has set_foo
<shevy>
like
<shevy>
your_object.set_foo "some new value"
<shevy>
then @foo would be that value
<drbrain>
WillMarshall: or you could just use attr_accessor :whatever
<lianj>
that too ;)
<shevy>
yeah that is shortest
Joeysomo has joined #ruby-lang
<WillMarshall>
Chur
rick123 has joined #ruby-lang
<shevy>
wat
<shevy>
Marrr!!!
<shevy>
do we make cat sound now
Natch| has joined #ruby-lang
<rick123>
ok, I feel dumb for asking this, but I am doing this so wrong and in such a non-eloquent manner, I figured I'd ask.
<rick123>
What's the best way to conditionally remove items from an array based on the items .length?
<petercooper>
Array#delete_if is one option
<rick123>
ah ok
<shevy>
#reject
<rick123>
Thank you, that is substantially better.
<petercooper>
alternatively, use reject if you don't want to remove items but get a new array with them removed
<petercooper>
And TBH, unlike him, I quite like FFI. But I probably haven't gotten far enough to get annoyed with it yet either ;-)
<deryldoucette>
nothing. *I* havne't seen any recent articles on how to write one, even one as mitchellh suggested of just doing an echo. I've subscribed to just about eveerything I can think of for ruby stuff, and thats definitely not one that I can honestly say I remember being covered. He mentioned there are a couple out there, but they're all dated.
<rohit>
I gave up on it long back, let the domain expire too
<petercooper>
I had a similar thing several years ago, same situation
<petercooper>
it's tricky
AndChat- has joined #ruby-lang
<rohit>
petercooper: Hmm ok, thanks.
<brownies>
the problem with such things is they go out of data very quickly
<brownies>
*out of date
<brownies>
at which point you basically have a less useful version of ASCIIcasts
burns180 has joined #ruby-lang
<rohit>
brownies: Basically requires a lot of work curating. Might as well rely on petercooper's newsletters and use your own bookmarking solution to keep track of things you need :P
<petercooper>
This is the thing
<rohit>
petercooper: btw you probably get this a lot but your newsletters are super awesome! :)
<petercooper>
I'm always looking up stuff I remembered linking in those. And I've had people ask me to look up stuff too.
<petercooper>
So I should probably implement a search across the entire archive.
<rohit>
petercooper: that would be awesome
<brownies>
hm, who is that one guy that has a paid email newsletter for ruby? or maybe rails?
<krzyhoo>
hey guys, anyone here at this insane hour?
sym- has joined #ruby-lang
<rippa>
how is it insane?
jimmy has joined #ruby-lang
burns180_ has joined #ruby-lang
<krzyhoo>
well
<krzyhoo>
7 in DE
<krzyhoo>
wehere are you at Rippa?
heftig has joined #ruby-lang
Zolrath has joined #ruby-lang
yxhuvud has joined #ruby-lang
burns180 has joined #ruby-lang
twittard has joined #ruby-lang
gokul has joined #ruby-lang
twittard has joined #ruby-lang
amerine has joined #ruby-lang
twittard_ has joined #ruby-lang
<rippa>
russia
<tonesfrommars>
It's a reasonable hour here in California.
<krzyhoo>
so it seems im in the middle
<krzyhoo>
but since the sun is already up
<krzyhoo>
i can manage
<krzyhoo>
ok guys
<krzyhoo>
have a question.
|Vargas| has joined #ruby-lang
|Vargas| has joined #ruby-lang
<krzyhoo>
I have a yaml configuration file with three levels: the most nested one describes a connection for a particular table,second to last for a db schema and third is a fallback
<krzyhoo>
now in order to dynamically select one connection parameter I am using this (and it works):
<andrewvos>
krzyhoo: I hope this code isn't being used in any sort of production application :|
<krzyhoo>
sort of
<krzyhoo>
it is a data anonymisation project
<krzyhoo>
but it is simple
<krzyhoo>
what you see in my yaml are just parameters for a program that creates a connection
<krzyhoo>
since the program can use all of those i had to implement that
<krzyhoo>
andrewvos: you with me there buddy?
<krzyhoo>
if you ask yourself why the nesting, the answer is, a table with the same name might exist in two groups
<andrewvos>
krzyhoo: Break your problems into small pieces and I'll help you. I disagree with that giant config file on a religous level though.
<andrewvos>
krzyhoo: Ok well use classes to solve your problem
<andrewvos>
krzyhoo: Construct a class relationship from that data
<krzyhoo>
andrewvos: a what? where do i read on that?
<andrewvos>
Make it so that the next person who uses your code doesn't want to chew their own face off.
tomzx has joined #ruby-lang
<andrewvos>
krzyhoo: Basically I mean map that data to some sort of class
<krzyhoo>
andrewvos: bummer. i actually thought it is a pretty slick way for a fallback scenario
<andrewvos>
An object that contains attribtues. Object.database_name or whatever
<andrewvos>
I don't get what you mean by fallback scenario?
<krzyhoo>
oh i get it
_ko1 has joined #ruby-lang
<krzyhoo>
well..if thetre is no connection defined for a table
<krzyhoo>
the fallback scenario is to grab connection details from a group
<krzyhoo>
and if no connection of defined for a croup, the fallback is to grab those of a project
<krzyhoo>
and the file you have seen serves two purposes
<krzyhoo>
the [yaml['p_EMPLOYEE']['g_SAMPLE_SCHEMA']['t_DEPT'], yaml['p_EMPLOYEE']['g_SAMPLE_SCHEMA'], yaml['p_EMPLOYEE']].compact.shift['par_connection_string'] part is in my ERB
<krzyhoo>
so that is takes the connection details of the finest granularity (closest to table)
<krzyhoo>
same file should serve as input for a program that creates the connection
<krzyhoo>
and this is the hard part
<Stereokitsune>
it blows my mind out
<andrewvos>
Yeah me too man
<krzyhoo>
as in order to create all the defined conenctions
<andrewvos>
krzyhoo: Too complex. Burn it and make it simple
<krzyhoo>
i need to un-nest the hashes
<andrewvos>
Take that yaml file out back and shoot it in the head.
<krzyhoo>
hmmm
<krzyhoo>
that makes me really sad
<krzyhoo>
I've seen some pretty fucked up code omn the net
<Stereokitsune>
also, is it right to save configurations for the site (like MySQL connection options) in YAML file?
<krzyhoo>
very important.
<krzyhoo>
this is not Rails app
<andrewvos>
Stereokitsune: Well I would just save them in ruby code. Ruby is just as readable as yaml. Otherwise store them somewhere externally. I like how heroku does it.
<krzyhoo>
the ERB describes is an XML file
<krzyhoo>
for a proprietary application
verto has joined #ruby-lang
<Stereokitsune>
andrewvos: I just wanted to make my simple app more useable by others. Or is it a bad habit after attempts to program in PHP?
burns180 has joined #ruby-lang
<krzyhoo>
well andrewvos I'll try and go with the Class for ConnectionParams
<andrewvos>
Stereokitsune: Don't think ahead too far man. Just get the job done.
<andrewvos>
ConnectionParameters.
rue has joined #ruby-lang
fayimora has joined #ruby-lang
rohit has joined #ruby-lang
znz_jp has joined #ruby-lang
dhruvasagar has joined #ruby-lang
AndChat| has joined #ruby-lang
tla has joined #ruby-lang
lsegal has joined #ruby-lang
burns180_ has joined #ruby-lang
<krzyhoo>
ok, fuck nestes hashes
<krzyhoo>
am going with proper naming conventions
<krzyhoo>
p_EMPLOYEE_g_SAMPLE_SCHEMA_t_DEPT
<krzyhoo>
p_EMPLOYEE_g_SAMPLE_SCHEMA
<krzyhoo>
p_EMPLOYEE
Joeysomo has joined #ruby-lang
chimkan__ has joined #ruby-lang
sandbags has joined #ruby-lang
toretore has joined #ruby-lang
rubyplusplus has joined #ruby-lang
verto_ has joined #ruby-lang
<rue>
Try object-oriented programming
<andrewvos>
That will never take off.
<darix>
rue: dont you think the overhead will be too high?
<rue>
Of using Ruby? Probably.
<krzyhoo>
it did :D
<krzyhoo>
flies like an angel now
Stefan__ has joined #ruby-lang
alim has joined #ruby-lang
<Stefan__>
Hi, I have a small problem. I have a hash {'foo' => 1, 'bar' => 2} and an array containing ['foo'] and I want to have the value of the hash at the key 'foo'. Normally I could do hash.value_at('foo') - but I want to do hash.value_at(['foo']) which doesn't work. How can I do what I want?
m3nd3s has joined #ruby-lang
knobo has joined #ruby-lang
mark_locklear has joined #ruby-lang
burns180 has joined #ruby-lang
<darix>
Stefan__: hash[array.first]
<darix>
Stefan__: hash[array[0]]
<darix>
array.map {|k| hash[k] }
<darix>
pick your poison^wsolution
<Stefan__>
darix: thanks, but the hash and the array are much longer than in my example here.
verto has joined #ruby-lang
<Stefan__>
darix: Basically I have an array containing all the keys of the hash where I want to have the values to
<darix>
Stefan__: then use the map line
<darix>
it will return you an array with all the values
<Stefan__>
darix: okay, with {|k| array.include? k} ?
<ankurgel>
using string there to remove trailing 's', rupee/rupees, euro/euros et al
<manveru>
yeah, that needs to_s then
<ankurgel>
Okay. So basically, to do something like 1000.rupees.in(:euros), I can just create in method in that class itself which will take a symbol as a param.
<ankurgel>
def in(:symb) #this?
<tobiasvl>
no
<tobiasvl>
just def in(symb)
<tobiasvl>
no colon there
<tobiasvl>
symb is a variable that holds the symbol
<ankurgel>
I should set indentation.. working on different machines is screw up
<Tasser>
ankurgel, I'd use a class to represent the currencies
rayners has joined #ruby-lang
Sailias_ has joined #ruby-lang
<canton7>
Tasser, so would most other people on here. It's part of their assignment, though, unfortunately
<ankurgel>
Tasser: class to represent currencies on it's own? Isn't creating class variable better way then that?
<canton7>
ankurgel, the point is you have a Currency class, which keeps track of the origin value, value in some base currency, current currency, etc. Then you might monkey-patch Numeric to have .rupee, etc, but these methods return an instance of Currency. #in is defined for Currency
Defusal has joined #ruby-lang
Defusal has joined #ruby-lang
<Tasser>
ankurgel, huh? class Currency; def in(symb); end; end; class Numeric; def mm(*args); ... Currency.new(self, args.first); end; end
<wubino>
(in regards to Ubuntu - > I like it, I fear upgrading to a newer distribution even if it is LTS)
<ankurgel>
try this, then reset terminal and check output of "type rvm | head -1"
robbrit has joined #ruby-lang
cesario has joined #ruby-lang
<wubino>
rvm is a function
<ankurgel>
bingo
slyphon_ has joined #ruby-lang
<ankurgel>
gem install pry
<ankurgel>
enjoy
<wubino>
assuming this works; what was wrong?
<ankurgel>
rvm was not a function. It should be function for gems to work.
<wubino>
Way to go ankurgel, it works!
<ankurgel>
wubino: rue was right, gemset wasn't actually necessary.
wmoxam has joined #ruby-lang
<ankurgel>
wubino: but good that you are now working on gemsets. Gives you opportunity to try other gems+ruby-ver combinations for your work
<wubino>
ankurgel: are you involved with it sdevelopment?
<ankurgel>
"it's" ?
<wubino>
yep
<wubino>
pry
<ankurgel>
what do you mean by 'it's' ? oh.
<wubino>
its'
<ankurgel>
oh
<ankurgel>
I installed it today itself. Looks cool.
Stefan___ has joined #ruby-lang
<ankurgel>
sophisticated and better than irb.
<wubino>
Any experience in python?
<ankurgel>
nope. ruby #FTW
<wubino>
Well, I am python programmer working on polishing some gems with ruby, but it has been baffling at times.
<ankurgel>
wubino: I'm not that experienced with gems either. Learning.
* canton7
cringes at the thought that someone might consider its' to be a valid word
<wubino>
sorry, I for got my english 101 -> I cringed too
<wubino>
How is Ruby OO but RVM a function??
sdeobald has joined #ruby-lang
judofyr has joined #ruby-lang
kurko_ has joined #ruby-lang
dejongge has joined #ruby-lang
<deryldoucette>
because RVM isn't part of Ruby. RVM is bash shell scripts.
<deryldoucette>
Ruby the language is Object Oriented. Bash is not, nor does it intend itself to be
ankurgel has joined #ruby-lang
scampbell has joined #ruby-lang
lchi has joined #ruby-lang
heftig has joined #ruby-lang
adambeynon has joined #ruby-lang
burns180_ has joined #ruby-lang
slyphon has joined #ruby-lang
unixabg has joined #ruby-lang
rippa has joined #ruby-lang
jbwiv has joined #ruby-lang
<unixabg>
Greetings, what is best way to pull and save web based mjpeg stream?
dv310p3r has joined #ruby-lang
enebo has joined #ruby-lang
fayimora has joined #ruby-lang
ryez has joined #ruby-lang
<sym->
(0..50).map { 'blah' } makes an array of 50 'blah's, gotta love ruby
Koia has joined #ruby-lang
<Koia>
Hey everyone
<judofyr>
hey Koia
<judofyr>
sym-: actually, that's 51
<shevy>
sym- 50.times.map { 'blah' } does too
<canton7>
sym-, so does ['blah'] * 50
<shevy>
:)
<judofyr>
canton7: not the same
<lianj>
sym-: (0..50) is 51 though
<ankurgel>
so does Array.new(50,'blah')
<judofyr>
canton7: that creates an array with 50 occurrences of the same string.
<Koia>
I got a question, but don't fall down reading it, I'm just trying to make sense to concepts I read. What is actually the difference between an Actor and an Object ? Couldn't we say an Actor is kind of a special Object ? I'm trying to oppose the actor-model and object-model and this difference is kinda hard to explain for me :/
<judofyr>
canton7: a = 50.times.map { 'blah' }; b = ['blah'] * 50; a[0].replace("nope"); b[0].replace("nope"); a == b # => false
<canton7>
judofyr, ah, of course. Forgot my pass-by-reference
<judofyr>
Koia: actors are asynchronous
<erikh>
actors belong to the SAG
<rue>
But, curiously, there's less sag among actors than any other group.
<robbrit>
what's SAG?
<andrewvos>
Screen Actors Guild
<andrewvos>
rue: Subtle
<rue>
I've been extra subtle this weekend
<judofyr>
subtlerue
cdnz has joined #ruby-lang
frem has joined #ruby-lang
<erikh>
ruetle
Stefan___ has quit [#ruby-lang]
malev_ has joined #ruby-lang
gray has joined #ruby-lang
coreydaley has joined #ruby-lang
Phrogz has joined #ruby-lang
Indian has joined #ruby-lang
burns180 has joined #ruby-lang
butchanton has joined #ruby-lang
vmatiyko has joined #ruby-lang
srbaker has joined #ruby-lang
dhruvasagar has joined #ruby-lang
jxie has joined #ruby-lang
chimkan has joined #ruby-lang
rushed_ has joined #ruby-lang
canton7 has joined #ruby-lang
<Asher>
anyone have ruby-debug working with 1.9.3?
dhruvasagar has joined #ruby-lang
<ddfreyne>
Asher: there is a ruby-debug19 iirc
<Asher>
yeah it seems not to compile properly w/1.9.3 and then once you either 1. modify 1.9.3 or 2. use the updated (but not pushed) version it segfaults
jmontross has joined #ruby-lang
<judofyr>
andrewvos: there is a debug.rb in 1.9
<judofyr>
oops
<judofyr>
Asher: there's a debug.rb in 1-9
<judofyr>
1.9*
<judofyr>
Asher: ruby -rdebug
<Asher>
the one using set_trace_func?
<Asher>
pry_debug (using set_trace_func) wouldn't work for this
<judofyr>
yeah
<judofyr>
why not?
<Asher>
not sure but i'm dealing w/code hanging and it also hung
sdeobald has joined #ruby-lang
<judofyr>
gdb?
<Asher>
it's ruby code i can't step through it w/gdb
<judofyr>
why do you want to step through it? just run it and see where it hangs
<Asher>
yep
<Asher>
how do i see where it hangs
<judofyr>
Ctrl-C
<judofyr>
and "bt" for backtrace
<Asher>
in gdb? but that will give me a backtrace of the VM not of the ruby stack
<Asher>
thanks - that's actually one of the sources i had been working from
<Asher>
tried everything there
<Asher>
which results in it loading as a gem
<Asher>
but then segfaulting at the first "debugger"
* workmad3
shrugs
<workmad3>
I don't use the ruby debugger
m3nd3s has joined #ruby-lang
sdeobald_ has joined #ruby-lang
<ankurgel>
quick question. If I'm working on master and a new_branch and commit any newly made change in master, it gets reflected automatically in new_branch?
<ankurgel>
I mean, no need to merge master in new_branch to do that?
francisfish has joined #ruby-lang
publicvoid__ has joined #ruby-lang
lightcap has joined #ruby-lang
lucas_ has joined #ruby-lang
<wubino>
Is there any reason why var will not show up in IRB but methods will from an imported script?
Avanine has joined #ruby-lang
hexo has joined #ruby-lang
H2H has joined #ruby-lang
<whitequark>
ankurgel: if we're talking about git, no.
<whitequark>
you need to merge new_branch with master
<whitequark>
wubino: because local variables are local to the context (script in this case), but methods are defined globally
<whitequark>
"def a; def b; end; end; a" leaks the definition of `b' to the global namespace too
<wubino>
how / can I make script variables global?
<whitequark>
use global variables
<whitequark>
$a = 1
<wubino>
Thanks!
<whitequark>
also: this is considered a bad coding practice. just so you'd know.
<shevy>
but ruby uses it a lot
<manveru>
it doesn't
<shevy>
$PROGRAM_NAME, $stdin ...
kaiwren has joined #ruby-lang
<whitequark>
in other words, if you'll try to write a big app with global vars you'll shoot yourself in the leg
<whitequark>
shevy: they're _actually global_, as they track the program itself
m3nd3s has joined #ruby-lang
<whitequark>
$stdin is a property of the process, not restricted to any particular ruby context
<whitequark>
(by the way, perlish $, $: $` and whatnot are definitely bad, but they'll probably be around forever for compatibility reasons)
sbabiy has joined #ruby-lang
<manveru>
$std* exists to make redirecting the standard ios easier
<shevy>
the $ are everywhere
<shevy>
even in your pants
<whitequark>
manveru: afaik redirecting io with $std* may lead to unexpected behavior
<shevy>
I can never remember what $` means
<whitequark>
like STDIN not matching $stdin
<whitequark>
shevy: I neither
<manveru>
whitequark: that's the goal
<shevy>
$: I finally know without having to look up
<Stereokitsune>
hm, who may recall any popular CLI software for Unix written in ruby?
<shevy>
Stereokitsune hmmmmm
<manveru>
all ruby methods use $stdin, STDIN exists if you really absolutely have no other option
<whitequark>
manveru: and what's the point of doing tht?
<robbrit>
whitequark: that explains why googling 'ruby english gem' did not give me the right results
<whitequark>
manveru: I understand how puts and friends work
<shevy>
why don't you use the japanese version require 'Engrish' ?
<whitequark>
shevy: rofl
<manveru>
whitequark: to demonstrate that puts uses $stdout and not STDOUT?
<whitequark>
manveru: I know that
<manveru>
same as gets uses $stdin
<manveru>
so you should do the same
<whitequark>
manveru: but by Unix semantics, stdin is fd 0, not some random variable in random code in random language
<manveru>
when's the last time i cared about unix semantics? :P
<shevy>
that's a lot of random
<Stereokitsune>
japanese version makes ruby code like misa language? :D
<shevy>
misa?
<shevy>
what is that
<shevy>
I know miso is the soup
<whitequark>
manveru: like now, because the OS you're using now follows Unix semantics in stdio
<shevy>
no worries whitequark, I'll convert manveru to RubyOS one day
<whitequark>
manveru: may it be windows or anything POSIX-compat
<manveru>
sorry, but what does that have to do with ruby?
<manveru>
you can always use IO.for_fd(1) if you don't want people to redirect stdout
heppy has joined #ruby-lang
<whitequark>
manveru: ruby misleads programmer into thinking that s/he should assign stdin (thus breaking unix semantics) instead of doing sane STDIN.reopen like any other language
<manveru>
ok, i give up, talking here is just pointless
<wmoxam>
heh
<whitequark>
before you do (I somewhat agree that it _is_ pointless), can you provide any valid example where redefining $stding while leaving fd 0 (or similarly for stdout/stderr) is actually sensible?
manojhans has joined #ruby-lang
tbuehlmann has joined #ruby-lang
manojhans has joined #ruby-lang
<shevy>
$stdin vs STDIN is confusing
<shevy>
matz should ignore 2.0 and move to 3.0 directly
<manveru>
no, because enough people use STDOUT/STDERR reopen instead of assigning to $stdout/$stderr to render my point useless
<manveru>
they're damn constants, why do people always try to change constants :(
<shevy>
because ruby allows them to change them
slimfit has joined #ruby-lang
<whitequark>
STDOUT.reopen doesn't change STDOUT at all
<shevy>
I think it was bad to make constants non-constants
<whitequark>
the fact that you can assign to constants is ruby's dirty secret. I'd say that this should be eliminated
<whitequark>
but STDOUT.reopen is a valid operation
rippa has joined #ruby-lang
<shevy>
what is the difference between $stdout.reopen and STDOUT.reopen?
<shevy>
you know what, I think there are two matzes
<whitequark>
shevy: none normally, because initially $stdout and STDOUT point to the same IO instance
<shevy>
they are constantly battling the design out in the matz-persona
<whitequark>
iirc it was the 1.8 edition in 2010 or early 2011
alim has joined #ruby-lang
<shevy>
a russian translation?
<whitequark>
of the book co-authored by mat
<whitequark>
*matz
<rue>
#include <istringstream>
slimfit has joined #ruby-lang
<whitequark>
rue: and what?
lucas_ has quit [#ruby-lang]
<shevy>
we are going back to the roots
<shevy>
evolution in programming languages starts in C
<shevy>
it makes me sad :(
<whitequark>
what
<deryldoucette>
it starts in B yeah thats it!
<deryldoucette>
though really assembler but..
<whitequark>
i'm starting to doubt either my or yours sanity
<shevy>
it is true!
<deryldoucette>
i doubt everyone's sanity. makes it simpler hehe
<whitequark>
maybe I should just go away and cry
<deryldoucette>
why?
JEG2 has joined #ruby-lang
<manveru>
whitequark: shevy was proven insane already
<shevy>
C is the grandaddy, C++ is the hipster son, Obj-C the old business son
<shevy>
granddaddy
<shevy>
then somehow Java got into things and messed everything up
<shevy>
even TIOBE :(
<deryldoucette>
if assembler isn't the right answer for evolution in programming languages starts in __. or B (since C came from B according to Ritchie and Kernigan) then what is?
<manveru>
whitequark: he's still building a "ruby operating system" that consists for bash aliases that modify themselves using genetic algorithms
<Mon_Ouie>
lambda calcul?
<deryldoucette>
whitequark: ok you got me there
<rue>
andrewvos: See how subtly I did that?
<shevy>
manveru ah I can't use bash in the long run, that must be replaced slowly :)
<manveru>
shevy: zsh?
<andrewvos>
rue: You Sir deserve a medal.
<deryldoucette>
but actually is machine code really a programming language? ;)
<whitequark>
manveru: either he's crazy, you're crazy, you are both crazy, I'm crazy or everyone likes
<whitequark>
*lies
<whitequark>
or all of the above
<rue>
andrewvos: OK, but only a very modest one.
<shevy>
manveru nah, for me bash and zsh are in the same boat, zsh is just better
<deryldoucette>
i vote for All of The Above
<whitequark>
deryldoucette: you can program in it. why not?
<deryldoucette>
whitequark: crap
<andrewvos>
rue: #include <medal>
<whitequark>
rue: hehe, nice one I'd say
<deryldoucette>
whitequark: stop makign sense! you're losing your right to be called insane! sheesh
<whitequark>
I'll earn my left to be called insane
<deryldoucette>
heh
<whitequark>
like, left now
<whitequark>
through I haven't actually right
<deryldoucette>
if left is right and right is left do two rights make a right or a lefT?
<shevy>
you are nuts
<deryldoucette>
I'M SO CONFUSED!
<shevy>
I think they neutralize one another
<shevy>
left + right = middle
* whitequark
is a peanut
<deryldoucette>
ok, now i'm *utterly* confused
<deryldoucette>
thanks for the hellish day that will entail
<whitequark>
achievement unlocked!
<deryldoucette>
hah!
<shevy>
deryldoucette I wonder about machine code too
<shevy>
can you code something that works like a human brain?
knobo has joined #ruby-lang
<whitequark>
I think that peasants are related to peanuts
<whitequark>
if you're calling yourself a sant then you're nuts
<shevy>
ok
<lianj>
shevy: if we had working blueprints
<shevy>
I shall call myself a saint then
<deryldoucette>
shevy: yeah because its at the same level as the machine. to me, and i'm sure NOT to the rest of the world, assembly would be the first language. isn't it marked as a 1G language?
<whitequark>
shevy: yes. you can code quantum equations, then you can just simulate the entire brain
<deryldoucette>
shevy: mental drival for the day :)
<shevy>
lianj well humans! they are out there everywhere!
<whitequark>
through it would take longer than the expected lifespan of universe
<whitequark>
hm, is "reverse engineering humans" an euphemism for "killing for science"?
<lianj>
shevy: tv's too. do you know how they work in every detail?
<shevy>
YES!
<lianj>
ofc ;)
<shevy>
:(
* whitequark
particularly likes lianj's "they"
<deryldoucette>
I read a book called The Footprints of God by Greg Iles that hit pretty much on that same thiong. (quantum programming)
<shevy>
I want my computer to be really clever
<deryldoucette>
s/io/i/
macmartine has joined #ruby-lang
<shevy>
well
<whitequark>
shevy: I want myself to be really clever
<andrewvos>
deryldoucette: Cool story bro.
<whitequark>
doesn't really work as it should
<deryldoucette>
andrewvos: you read it?
<shevy>
quantum programming sounds easier than coding something that genuinely works like a human brain
<deryldoucette>
good book
<shevy>
whitequark, I gave up that quest for myself a long time ago
burns180 has joined #ruby-lang
<andrewvos>
rue: Am I getting better? ^
<shevy>
andrewvos, the andies will FOREVER rule!!!
<andshevy>
hi andrewvos
<deryldoucette>
isbn 978-1-4165-6409-6 for those even remotely interested
<andshevy>
where is andkerosine when you need him...
<rue>
andrewvos: Better, but still a little heavy-handed
<whitequark>
shevy: human brains can be thoroughly implemented with an arduino
<andshevy>
deryldoucette you mean for those even remotely insane? :)
<deryldoucette>
andshevy: haha!
<whitequark>
eat. drink. sleep. have sex. write nonsense in #ruby-talk
<andshevy>
whitequark, ok I shall remember that the next time I see an arduino
<deryldoucette>
whitequark: oh, a good day!
<andshevy>
lol
<whitequark>
andshevy: use an anduino instead
<andshevy>
now that's quite a life an arduino has here
<whitequark>
also: they're more clever than they look like
<whitequark>
and they spy on you
<whitequark>
and plot
<andshevy>
do they spy with or without the sex or during the sex?
<whitequark>
both
<andshevy>
hmm
<andshevy>
perhaps computers should not be too clever after all
<whitequark>
too late
<deryldoucette>
don't hold me to it, but i believe thats what was the basis of a TINY ass system a friend showed me. looked like a friggin USB stick with a usb port on one end and a hdmi port on the other. its a full damned system!
<andshevy>
deryldoucette is he a TERRORIST HACKER
<deryldoucette>
has 8GB flash drive in it for storage. funky little thing. never seen anything like it
<deryldoucette>
andshevy: hehe, no he's one of those guys that sees interesting stuff and just has to buy it
<whitequark>
deryldoucette: yeah, but that was somewhat more powerful than an arduino. it definitely had a microcontroller core inside, some flash memory, and a hw hdmi encoder
<andshevy>
ah ok deryldoucette
<whitequark>
and the microcontroller probably was something from ARM family
<deryldoucette>
doesn't know dickall about programming, how to run linux ect, but he's *constantly* buying these little gadget things
Jay_Levitt has joined #ruby-lang
<andshevy>
one of my friend is like that when it comes to apple... every i* wave he has to buy ...
<lianj>
andshevy: twice!
<deryldoucette>
andshevy: hehe yeah he's always bugging me for info because I do know linux and how to code ect ect.
manojhans has joined #ruby-lang
<andshevy>
hehe
<deryldoucette>
one of those guys that always calls at supper and says you gotta come NOW NOW NOW and check XYZ out that I just got!
<whitequark>
andshevy: why is he still alive if you're around? should have been dead long ago because of trolling overdose
manojhans has joined #ruby-lang
<whitequark>
deryldoucette: can you cite entire linux source code from your memory?
<deryldoucette>
whitequark: to the ARM comment, that might be. I haven't seen a spec sheet on it. I should call and bug HIM for a change hehe
<deryldoucette>
whitequark: shit no
<deryldoucette>
I'm crazy not stupid
<whitequark>
deryldoucette: well I'm fairly certain it is ARM. might also be MIPS, but that's less frequently used core
<whitequark>
not much other variants
<deryldoucette>
whitequark: was really weird. never seen anything like it before. cool as hell. probably not emmensely useful, but was definitely trippy
manojhans has joined #ruby-lang
<whitequark>
deryldoucette: I'd say it _is_ useful, at least if/when there'll be widespread hdmi adoption
<deryldoucette>
yeah but just how powerful could the thing be?
<whitequark>
deryldoucette: you don't really need much power if you have hardware video encoder
<deryldoucette>
i mean its about as big as the damned usb sticks you get from walmart
<deryldoucette>
ehh i can see that point
* Stereokitsune
feels a stupid reading all of this
<deryldoucette>
for you to have hdmi don't you *have* to have hw vid enc/dec?
<whitequark>
the core just DMA's some bytes from the flash, then DMA's them again to the hw encoder (or maybe recoder. it has to know MPEG/h264/etc.)
burns180 has joined #ruby-lang
<lianj>
do you need a HD encoder for output, no decoder?
<whitequark>
deryldoucette: hdmi video isn't compressed over the wire afaik
<whitequark>
it's like digital VGA
burns180 has joined #ruby-lang
<deryldoucette>
god there's just so much to learn hehe
<whitequark>
so there is no such thing as "HDMI codec"
<deryldoucette>
easily go into info overload :)
<shevy>
whitequark I am not trolling! :(
<lianj>
shevy: thats the sad part :P
<whitequark>
it can be encrypted through if HDCP is used, and you definitely want hardware support for this
<deryldoucette>
doh!
<deryldoucette>
whats the C in that?
<whitequark>
copy protection
<shevy>
deryldoucette yeah but also remember, the more you know, the more you forget as well!
<whitequark>
but some stupid/nice (depends whether you work for MPAA) guy has leaked the key from Intel
<deryldoucette>
hehe love your quantifier there
<whitequark>
and I like how you used the word "quantifier"
byped has joined #ruby-lang
<deryldoucette>
I understand the RIAA/MPAA stance. I just think A) they're overly draconian and B) they definitely do NOT pay their artists enough
<whitequark>
they don't understand how digital media works
<whitequark>
that's the main issue
<whitequark>
they think that you can somehow restrict a video so that it could be played but not copied
<whitequark>
this is FUBAR because playing = copying (to video RAM)
looopy has joined #ruby-lang
virunga has joined #ruby-lang
<whitequark>
even worse, they're trying to solve a social problem (people not wanting to pay, at least according to MPAA), with a technical solution
<whitequark>
that fucking never works
<whitequark>
never.
<deryldoucette>
they don't understand how a lot of things work, i fear. they did studies that showed that around college towns/areas where torrents of music and the like were rampant that their sales rates went *up* because the kids wanted their own copies. RIAA tried to have that study squashed before it was released
<whitequark>
they're greedy, crazy, and stupid
<whitequark>
they will die
<deryldoucette>
agreed
<whitequark>
it is a matter of time
<deryldoucette>
when the populace has finally had enough all together, they're not going to like the consolidated backlash.
<deryldoucette>
and i'm not sure they'll survive it
<lianj>
whitequark: like capitalism?
gianlucadv has joined #ruby-lang
<whitequark>
they only have the time until the generation who has sharing & torrents in their genes will be at the right age to throw them out
<deryldoucette>
capitalism should be renamed GREED :)
<lianj>
but its alive and still growing :(
<deryldoucette>
whitequark: actually i think they know that and thats why they're targetting my kids.
<whitequark>
lianj: I'd say that you never have "pure" capitalism, or "pure" communism or whatever. every political system is a crazy mix, and you really shouldn't analyze them out of context
<andrewvos>
deryldoucette: Targeting*
<deryldoucette>
lianj: unfortunately. I mean the original idea of capitalism i don't have a problem with. its when control of the markets is embedded in the few that we have problems
manoj has joined #ruby-lang
<deryldoucette>
oh single t?
<andrewvos>
deryldoucette: No there's two
<erikh>
i farted
* deryldoucette
heads for the febreeze can
<andrewvos>
erikh: You add such value to our chats
<deryldoucette>
andrewvos: actually if you look at where they're heading the really seem to be targetting the kids especially. they're the ones growing up with torrents and the like as mainstream.
<deryldoucette>
andrewvos: lol
<erikh>
andrewvos: I do.
<andrewvos>
deryldoucette: Targeting*
<whitequark>
deryldoucette: they look like stupid old farts to the kids (which they are), so they'll never win that
<whitequark>
and it's good
<deryldoucette>
guh
<deryldoucette>
wow i am so slow at times. 2 Ts. I was meaning back to back, andrewvos meant in the entire word.
* deryldoucette
is a numbnut sometimes
<deryldoucette>
erikh: thats it you fart one more time, I'm sticking you in a closet with my rottie after she has anything with milk
<whitequark>
andrewvos: grammatik macht frei?
naz has joined #ruby-lang
achiu has joined #ruby-lang
<andrewvos>
whitequark: Freedom through grammar?
<whitequark>
andrewvos: kinda. google for the phrase.
<andrewvos>
whitequark: I know the phrase
facefox has joined #ruby-lang
solars has joined #ruby-lang
<shevy>
phrase for the google
Fullmoon has joined #ruby-lang
<shevy>
grammatik is overrated in today's hipster generation
<andrewvos>
How old are you shevy?
<Phrogz>
Gammar Nazi's Unite!
headius has joined #ruby-lang
<Stereokitsune>
why google translate doesn't know slanguages :(
<shevy>
@treeyears = @treeyears + 1 to @treeyears += 1
<shevy>
etc..
<Stereokitsune>
and if I understand ruby fine, you may use case..when instead of a lot elsifs
imperator has joined #ruby-lang
<imperator>
greetings programs
<Stereokitsune>
hi
<shevy>
darth imperator has arrived
<shevy>
anyone caught smiling will be disciplined!
<Stereokitsune>
grammaton cletic?
<workmad3>
the flogging will continue until morale improves!
<workmad3>
gray: also, I'd probably take it as bad practice that when the tree dies, it kills the entire ruby process with an 'exit'. What about any other orange trees you have that aren't as old as this one?
<gray>
Stereokitsune where i should use loops?
bababa has joined #ruby-lang
bababa has quit [#ruby-lang]
<shevy>
workmad3 all orange trees must die
<Stereokitsune>
gray: too many oneYearPasses calls
<Stereokitsune>
i think
dr_bob has quit [#ruby-lang]
<gray>
shevy: thanks for this @treeyears = @treeyears + 1 to @treeyears += 1
<Asher>
if i use #method_missing and conclude the method is actually missing, is there a way to re-raise the exception at the line that called method_missing?
<workmad3>
shevy: but then where will I get my orange juice?
<gray>
shevy: this nice
<shevy>
workmad3 with apples + chemical flavour modifications of course :)
<workmad3>
Asher: just call super in the case of your own method_missing not handling the case
<Stereokitsune>
workmad3: juice is the blood of the trees, don't you feel sorry for them?
futurechimp has joined #ruby-lang
<shevy>
pffft
<shevy>
take some juice won't kill anyone
<shevy>
that's what the vampires found out a long time ago
<shevy>
but then they got greedy
<shevy>
and hunted down
<shevy>
sad story :(
<cout>
you know this from experience?
<shevy>
cout I saw this in movies!
<shevy>
lost boys, interview with a vampire and the vampire hunters!
robbrit has quit [#ruby-lang]
<workmad3>
shevy: and twilight!!!
<shevy>
oh no
mark_locklear has joined #ruby-lang
<Stereokitsune>
May the vampire be written as a class?..
<shevy>
I have managed to avoid twilight
<workmad3>
oh wait, that's not a film about vampires... it's a film about stupid sparkly fairies that drink blood...
<Asher>
workmad3 - perfect, thanks
<shevy>
I would not know! but I dont feel like its target audience, it seems to cater to people +20 years younger than I am!
zmack has joined #ruby-lang
<workmad3>
Asher: and a quick bit of ruby knowledge - when you hit method_missing, no exception has been raised... the NoMethodException is what happens in the default method_missing, not something that prompts a method_missing call ;)
<workmad3>
shevy: what? you're only 21? :)
<Asher>
workmad3 - yea good point
<lianj>
Asher: call super
darkf has joined #ruby-lang
Tearan has joined #ruby-lang
trappist has joined #ruby-lang
<trappist>
undefined method `capture3' for Open3:Module <-- I can see it right in the docs, did this get removed in 1.9.3 or something?
<ankurgel>
imperator: again, same thing. I need to push this rails project on heroku. It use PostgreSQL. When I do 'bundle install' it fails with same error as in that logfile.
<ankurgel>
consequently can't push it. :/ Solution?
<ankurgel>
"You may have to install gems with bundle install --without production to ignore the PostgreSQL gem for your local installation."
<ankurgel>
how do I ignore that? When I change in Gemfile, it does work but again, heroku deployment fails!
dejongge has joined #ruby-lang
<burgestrand>
ankurgel: you can either make it possible to install the pg gem locally, or you can put the gem inside the :production group inside your Gemfile and follow the advice with "--without production"
Banistergalaxy has joined #ruby-lang
kurko_ has joined #ruby-lang
slimfit has joined #ruby-lang
Natch has joined #ruby-lang
<ankurgel>
done! :)
macmartine has joined #ruby-lang
kurko_ has joined #ruby-lang
ezkl has joined #ruby-lang
jeremytarling has joined #ruby-lang
postmodern has joined #ruby-lang
Nisstyre has joined #ruby-lang
dfr|mac has joined #ruby-lang
y3llow_ has joined #ruby-lang
leonL has joined #ruby-lang
s0ber_ has joined #ruby-lang
kurko_ has joined #ruby-lang
dfr|mac_ has joined #ruby-lang
y3llow has joined #ruby-lang
FACEFOX has joined #ruby-lang
y3llow has joined #ruby-lang
y3llow has joined #ruby-lang
ankurgel has joined #ruby-lang
y3llow has joined #ruby-lang
fayimora has joined #ruby-lang
hagebake has joined #ruby-lang
hagebake has joined #ruby-lang
macmartine has joined #ruby-lang
Teddy2steper has joined #ruby-lang
ankurgel has quit [#ruby-lang]
stephenp has joined #ruby-lang
malev_ has joined #ruby-lang
slimfit has joined #ruby-lang
havenn has joined #ruby-lang
<stephenp>
i feel like i'm being stupid here. i've got a spork / guard / rspec combo working for my non-rails project. i added a coverage rake test, and can run the task - my spec files are required, but the specs themselvs are never executed. what am i missing?
havenn has joined #ruby-lang
mighty_max has joined #ruby-lang
adambeynon has joined #ruby-lang
io_syl has joined #ruby-lang
<Fullmoon>
Wasn't there a short way to get the ascii value of a character?
<mighty_max>
ord?
<rue>
stephenp: Why do you have a spork for not rails?
<stephenp>
shorter version - requires a lot of database setup to get going
<Fullmoon>
I could have sworn it was ?a
<Fullmoon>
But that just returns "a"
<mighty_max>
Fullmoon: ?foo is shorthand for declaring Strings
<Fullmoon>
mighty_max: Hm, maybe it was returning numbers in 1.8?
<matled>
Fullmoon: yes, in 1.8 ?x and "x"[0] used to return the numeric value of the byte
<mighty_max>
yeah they changed that in 1.9
<matled>
Fullmoon: in 1.9 you can use #bytes on a string
<Fullmoon>
Oh never mind, I'll just use the bytes enumerator
<Fullmoon>
Ah, hehe, thanks @matled
benanne has joined #ruby-lang
<Fullmoon>
I want an array of the first four anyway... stream.bytes.take(4).to_a # <3 enumerable
<Fullmoon>
first four bytes
zmack has joined #ruby-lang
cored has joined #ruby-lang
<jmontross>
why not just take a checksum of file?
<Fullmoon>
jmontross: Do you mean me? I am trying to guess the file type given the first four bytes, like `file'
<cored>
hello
<mighty_max>
Fullmoon, there's a gem for that. Unless this is for learning purposes
<mighty_max>
cored, I get blue, red, other. as expected
<mighty_max>
what version are you using?
t has joined #ruby-lang
<cored>
1.9.2
<mighty_max>
I'm stumped. You running that in irb?
<cored>
nop
<theconartist>
did you not read the error cored ?
<theconartist>
the string you are comparing it too doesn't have the method #color
srbartlett has joined #ruby-lang
<theconartist>
you are calling 'this time operator works!'.color
<burgestrand>
don’t forget to use respond_to? in your #===
<cored>
theconartist: oh ok
<cored>
you mean the method call in initialize for the Car class?
<mighty_max>
oooh. I thought he was getting different output in the switch and the String error was intentional
<cored>
theconartist: ?
<burgestrand>
cored: no
<burgestrand>
cored: Car.new('blue') === object_that_does_not_respond_to_color # <- what will happen?
fayimora has joined #ruby-lang
<shevy>
the car will be blue
<shevy>
:)
<cored>
burgestrand: yes but I'm not talking about that
<cored>
burgestrand: the switch is going directly to else not getting inside "does not work in case" with the "yellow" call
<burgestrand>
cored: as for your case/when statement, the string will be the left-hand side of the comparison, it will become: "does not work in this case" === car
<cored>
that's what I don't get
<cored>
I did that un purporse my problem is with the 29 line
<burgestrand>
and since String#=== does not match your car, it will return false
<cored>
hm
<mighty_max>
in general, === isn't reflexive. 2 === (1..3) # false; (1..3) === 2 # true
<mighty_max>
joystick.event calls the C read function, which is blocking. But even though it's in its own Thread it still blocks the other one
<burgestrand>
mighty_max: you’ve written it?
<mighty_max>
yeah
<burgestrand>
mighty_max: have a look at rb_thread_blocking_region
<burgestrand>
mighty_max: if you want to allow ruby to run other threads while doing blocking calls in C you’ll need to unlock the GVL for the duration of that blocking call
<mighty_max>
would that be in the extension or in the script?
<burgestrand>
mighty_max: in the extension
<burgestrand>
mighty_max: have you ever heard of the GIL/GVL before?
<cored>
can I do something like this
<mighty_max>
yeah, never had problems with it though
<cored>
array = Array.new
<cored>
def array.===()
<cored>
end
<cored>
?
kylemcgill has joined #ruby-lang
<burgestrand>
mighty_max: essentially, while your C function is blocking, it is still holding the GVL so ruby cannot run any other threads in parallel
<mighty_max>
cored: you want define_singleton_method I think
<burgestrand>
cored: yes you can, but it’s considered evil to override methods on core classes
<burgestrand>
but in this case it’ll be okay, since it’s not a global change
<burgestrand>
but still in this case it’s considered a bit bad form, but is sometimes necessary to hack around things
<cored>
burgestrand: yes
<cored>
I just want to have some pattern matching
<cored>
in Ruby
<burgestrand>
remember that when you stand on the edge of apocalypse
<mighty_max>
burgestrand: awesome! that should do it
<burgestrand>
mighty_max: don’t forget the unblocking function, it’s important to have if you want to interrupt the blocking call, say if you ^C your script to exit it or whatever
<burgestrand>
(it’s not always possible, but if it is do use it)
<mighty_max>
I've seen that used in other extensions, never knew what it did
<burgestrand>
mighty_max: ruby use it in bignum.c when calculating huge numbers, to allow the calculations run in parallel with other threads :)
<burgestrand>
(probably other places too)
workmad3 has joined #ruby-lang
<cored>
don't know why people doesn't do this more often
<apeiros_>
gotta go do some stuff first, but will be back in ~10min
<cored>
oki doki
virunga has joined #ruby-lang
FACEFOX has joined #ruby-lang
srbaker has joined #ruby-lang
slimfit has joined #ruby-lang
<apeiros_>
cored: back. I just noticed what you do is a bit different from what I thought you do, so maybe may patterns is not the best, it is probably still worth a look…