<shevy>
x = foo(x) if "method foo exists anywhere" ?
<whitequark>
x = foo(x) if respond_to? :x
<shevy>
I have a class, that can call a method that is defined in another .rb file. But that other .rb file may exist, or not. In both cases the class should continue to work
<whitequark>
and I would politely suggest not to use global methods, because by using them you are more likely to produce spaghetti code
Jade has joined #ruby-lang
tjgillies has quit [#ruby-lang]
<theconartist>
shevy: that sounds like a horribly unreasonable situation
<whitequark>
^ that
<whitequark>
#respond_to? is really useful with duck typing
<whitequark>
take, for example, Rack: a Rack application is an object for which "obj.respond_to?(:call) == true"
<whitequark>
that may be a Proc, or your own class, or whatever
<whitequark>
rack server won't care
<whitequark>
it does not need to, as all it uses is the #call method
<any-key>
if you're doing anything with multiple parts of the twitter API you may want to consider a gem
<andrewhl>
oh, can you recommend one?
<any-key>
there's some good ones out there for handling OAuth and whatnot
<any-key>
heh not off the top of my head, but I know google can :)
<andrewhl>
ok, I'll check it out. Thanks!
<any-key>
I used one for the streaming API, but other than that I was just playing with the OAuth part myself
<andrewhl>
I'm just trying to do a search for specific hashtags at the moment, nothing elaborate
<any-key>
eh, if you're just doing GET requests a gem is silly
<any-key>
especially if it's all of the same kind of request
<any-key>
I wouldn't worry about a gem in your case :P
<andrewhl>
ok
Tref has joined #ruby-lang
<whitequark>
andrewhl: twitter gem
<erikh>
yeah the twitter gem is mostly unfail
<whitequark>
unfail?
jtoy has joined #ruby-lang
volty has joined #ruby-lang
<andrewhl>
the opposite of fail
<whitequark>
captain obvious to the rescue?
banisterfiend has joined #ruby-lang
banister_ has joined #ruby-lang
ramonmaruko has joined #ruby-lang
porcelina has joined #ruby-lang
porcelina has quit [#ruby-lang]
wardrop has joined #ruby-lang
<wardrop>
What's the best way to remove a string from the beginning of another string? E.g. remove "dog" from "dog_cat", but not from "horse_dog"
<wardrop>
Regex is the only method I can think of, but the word to be replaced will be dynamic, so dynamically building a regex is something I want to avoid.
<lianj>
"dog_cat"["dog".bytesize..-1] ?
<whitequark>
wardrop: str1.slice![0...str2.size] if str1.begin_with? str2
<whitequark>
note the three dots. the range constructed by three dots is not the same as the range constructed by two dots (C.O.); the former does not include the last element
<wardrop>
I had though of that solution actually. I guess it's the best option without resorting to regex. Maybe I'll just go with regex?
<whitequark>
also, as a side note, keep in mind that (g)sub family functions actually construct a regex inside even if you pass it a string pattern
<whitequark>
at least in MRI
frequency9 has joined #ruby-lang
<wardrop>
Is Regexp.new(str) the shortest way to create a a regexp object from a string?
<whitequark>
you can use string interpolations within a regex, like /^#{pattern}/
<josh9>
i have a controller that uses a method on a model, that uses a method on another object. the last method is an API call to external service. where is the best place to wrap the code with begin-rescue? the last class?
eggman2001 has joined #ruby-lang
<eggman2001>
can someone tell me what command I can use to exit a method?
<josh9>
eggman2001: return?
<eggman2001>
josh9: thanks
dc5ala has joined #ruby-lang
ovnimancer has joined #ruby-lang
n0man has joined #ruby-lang
srbartlett has joined #ruby-lang
krz has joined #ruby-lang
MistyM has joined #ruby-lang
takaokouji has joined #ruby-lang
ramu3_ has joined #ruby-lang
havenn has joined #ruby-lang
rohit has joined #ruby-lang
looopy has joined #ruby-lang
cmatheson has joined #ruby-lang
krzkrzkrz has joined #ruby-lang
krzkrzkrz has joined #ruby-lang
krz has joined #ruby-lang
JohnBat26 has joined #ruby-lang
eggman2001 has quit [#ruby-lang]
cmatheson has quit [#ruby-lang]
takaokouji has joined #ruby-lang
Heimidal has joined #ruby-lang
x0F__ has joined #ruby-lang
JohnBat26 has joined #ruby-lang
thone has joined #ruby-lang
yxhuvud has joined #ruby-lang
QoQOoO has joined #ruby-lang
solars has joined #ruby-lang
QoQOoO has joined #ruby-lang
gianlucadv has joined #ruby-lang
|Vargas| has joined #ruby-lang
|Vargas| has joined #ruby-lang
QoQOoO has quit [#ruby-lang]
QoQOoO has joined #ruby-lang
QoQOoO has quit [#ruby-lang]
QoQOoO has joined #ruby-lang
fragrant has joined #ruby-lang
<fragrant>
zenspider: Hi, i was asked to ask question here to you about ruby scalability problem, Can you tell
<fragrant>
me actually what does it mean by ruby scalability problem?
<fragrant>
i was told from #ruby to ask here
<erikh>
fragrant: someone was trolling you
<erikh>
short of getting kb'd I'd say they've succeeded
<fragrant>
What is ruby scalability problem?
<erikh>
your grammar doesn't scale
<wardrop>
haha
sdeobald has joined #ruby-lang
erpuds has joined #ruby-lang
mikeric has joined #ruby-lang
fragrant has joined #ruby-lang
<fragrant>
What is ruby scalability?
<fragrant>
What is ruby scalability problem?
erpuds_ has joined #ruby-lang
steven_ has joined #ruby-lang
mytrile has joined #ruby-lang
<manveru>
fragrant: ruby doesn't scale
<manveru>
so it doesn't have any scalability problems
<fragrant>
manveru: What does it mean by scalability problem?
<josh9>
i have a controller that uses a method on a model, that uses a method on another object. the last method is an API call to external service. where is the best place to wrap the code with begin-rescue? the last class?
roadkith has joined #ruby-lang
tjadc has joined #ruby-lang
<yorickpeterse>
Morning lads
mikeric has joined #ruby-lang
wardrop has joined #ruby-lang
JohnBat26 has joined #ruby-lang
wardrop has joined #ruby-lang
gja has joined #ruby-lang
chimkan___ has joined #ruby-lang
retro-in-better- has joined #ruby-lang
cyri_ has joined #ruby-lang
Dreamer3 has joined #ruby-lang
erpuds has joined #ruby-lang
fayimora has joined #ruby-lang
chimkan has joined #ruby-lang
twelvechairs has joined #ruby-lang
twelve_chairs has joined #ruby-lang
daglees has joined #ruby-lang
achiu has joined #ruby-lang
ryez has joined #ruby-lang
tekin has joined #ruby-lang
futurechimp has joined #ruby-lang
<shevy>
die!
chrismcg has joined #ruby-lang
<shevy>
oops, wrong idiom
<shevy>
hi!
virunga has joined #ruby-lang
yango_ has joined #ruby-lang
morticed has joined #ruby-lang
kitallis has joined #ruby-lang
burgestrand has joined #ruby-lang
twelvechairs has joined #ruby-lang
znouza has joined #ruby-lang
frangiz has joined #ruby-lang
jstemmer has joined #ruby-lang
<roadkith>
whats the best midi lib for ruby?
kitallis has joined #ruby-lang
looopy has joined #ruby-lang
at5l has joined #ruby-lang
jstemmer has joined #ruby-lang
kvik has joined #ruby-lang
<kvik>
hello. anyone here using aptana for ruby, please? i'm having trouble debugging ruby scripts
benanne has joined #ruby-lang
wardrop has joined #ruby-lang
<yorickpeterse>
Trouble such as?
<kvik>
yorickpeterse: if i set breakpoint, aptana won't stop on it
<kvik>
*if I
<yorickpeterse>
What version of Ruby are you using? I'm not familiar with Aptana but perhaps their debugger doesn't work with 1.9
<kvik>
I'm using ruby 1.9.3 and latest aptana.
<yorickpeterse>
You might also want to give Pry a try (github.com/pry/pry), it's not a fully fledged debugger but it does come with support for breakpoint like behaviour that works regardless of your editor
<yorickpeterse>
or Ruby version
<kvik>
thank you. but ruby debugger seems to be working when launched in terminal via rdebug with breakpoints working.
<yorickpeterse>
It might not work properly with Rack apps
<yorickpeterse>
I think your best bet is Aptana's support forum/group/whatever they use, I'm not sure if anybody in here uses Aptana (at least not that I know of)
<kvik>
everyone uses Vim or TextMate here? :)
<tobiasvl>
vim <3
<yorickpeterse>
Oh, there we go
kitallis has joined #ruby-lang
wardrop has joined #ruby-lang
<kalleth>
kvik: oh god, incoming emacs
xjonc has joined #ruby-lang
<yorickpeterse>
I use ed myself
<andrewvos>
I just use echo and redirection
kitallis has joined #ruby-lang
Phlogistique has quit [#ruby-lang]
razumasu has joined #ruby-lang
Spooner has joined #ruby-lang
kitallis has joined #ruby-lang
seanstickle has joined #ruby-lang
kitallis has joined #ruby-lang
achiu has joined #ruby-lang
Danzer has joined #ruby-lang
looopy has joined #ruby-lang
kitallis has joined #ruby-lang
seanstickle has joined #ruby-lang
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
apeiros_ has joined #ruby-lang
fayimora_ has joined #ruby-lang
fayimora_ has joined #ruby-lang
razumasu has quit [#ruby-lang]
brownies- has joined #ruby-lang
kitallis has joined #ruby-lang
rohit has joined #ruby-lang
rohit has quit [#ruby-lang]
stamina has joined #ruby-lang
wardrop has joined #ruby-lang
ramonmaruko has joined #ruby-lang
steven_ has joined #ruby-lang
looopy has joined #ruby-lang
rohit has joined #ruby-lang
wardrop has joined #ruby-lang
jbsan has joined #ruby-lang
bryanl has joined #ruby-lang
dhruvasagar has joined #ruby-lang
FiXato has joined #ruby-lang
rohit has joined #ruby-lang
niklasb has joined #ruby-lang
wardrop has joined #ruby-lang
kitallis has joined #ruby-lang
fayimora_ has joined #ruby-lang
vdrab has joined #ruby-lang
testor1 has joined #ruby-lang
mark_locklear has joined #ruby-lang
kitallis has joined #ruby-lang
tomzx has joined #ruby-lang
<testor1>
Hello,Can I use Japanese here ?
dv310p3r has joined #ruby-lang
<apeiros_>
testor1: I think there's a dedicated japanese ruby channel
<apeiros_>
probably #ruby.jp, #ruby-jp or somesuch
kitallis has joined #ruby-lang
<apeiros_>
seems to be #ruby-ja
testor1 has quit [#ruby-lang]
fayimora has joined #ruby-lang
stephenp has joined #ruby-lang
<masterkorp>
i like boobs
Defusal has joined #ruby-lang
Defusal has joined #ruby-lang
<andrewvos>
masterkorp: You should meet shevy
<apeiros_>
shevy got boobs?
QaDeS has joined #ruby-lang
jbsan has joined #ruby-lang
Gekz has joined #ruby-lang
Gekz has joined #ruby-lang
wardrop has joined #ruby-lang
fayimora has joined #ruby-lang
workmad3 has joined #ruby-lang
Oloryn_lt1 has joined #ruby-lang
mytrile has joined #ruby-lang
Xzyx987X has joined #ruby-lang
Sailias has joined #ruby-lang
<shevy>
apeiros_ yeah but I am losing weight!
krz has joined #ruby-lang
codewrangler has joined #ruby-lang
jxie has joined #ruby-lang
<shevy>
hmm
<shevy>
I am going to learn japanese by staying on #
<apeiros_>
where blacklist can of course come from Dir.glob as well…
<Spooner>
Well, the argument is that if your project it on Github and thus all forks will be on Github and have been checked out with git, it seems silly to say that "not everyone has git" :D
<manveru>
just do it that way, and keep your gemspec without dependencies :)
<apeiros_>
just because your project is on github it a) doesn't mean somebody gets it from there and b) even if, it doesn't mean somebody *clones* the repo (as I did, I downloaded it)
<apeiros_>
Spooner: anyway, I'll repeat, it does ABSOLUTELY NOT MATTER that it is `git`. what matters is that your gemspec has a dependency. that's a fucking fail.
<apeiros_>
and as a programmer you should know that.
<manveru>
apeiros_: and you can't just add it to your $RUBYLIB ?
darkf has joined #ruby-lang
<apeiros_>
manveru: hm? what? the gem? no, I downloaded and built it because the gem on rubygems was broken (broken gemspec - oh what irony…)
<apeiros_>
and to get bundler to install my bundle, I manually installed the gem
<manveru>
oh, bundler
<Spooner>
apeiros_: If you download the tarball, then why create the gem from it (if you aren't editing the code) rather than just using gem or is gem an unreasonable dependency for a gem?
<apeiros_>
am I ranting on payroll? that's nice actually…
<manveru>
well, two fails at once make big fail :)
<apeiros_>
Spooner: ^
<apeiros_>
Spooner: again, you're missing the point
<apeiros_>
Tasser: I'm fine if people generate the .gemspec
<apeiros_>
and include the generated
<Spooner>
VERSION would be harder to put into a purely data-based gemspec.
<Tasser>
oh, yet another layer of abstraction
<manveru>
oO
<darix>
Spooner: how so?
<manveru>
i never write gemspecs by hand, do you?
<apeiros_>
nope. why would I? as said, the pastie was generated from a template…
<Spooner>
darix: Common practice is to define VERSIOn in your app and include the version.rb in the gemspec. Admittedly, if gemspec forced you to define version in a very particular way in your project then you wouldn't break DRY.
<manveru>
...
<manveru>
what planet do you live on?
<darix>
manveru: one where we dont want to be :)
<manveru>
right now gemspecs are executable, and it does silly stuff like if/else to compensate for rubygems differences
<Tasser>
WTF... I parse an XML 3 times in my app :-/
<manveru>
it only requires one file and doesn't require it in the gemspec
<yorickpeterse>
Again, how is that better? :)
<manveru>
your complaint was that i have to require all files in the project?
<yorickpeterse>
What I meant was how that was better than requiring lib/foo/version in the gemspec itself
<apeiros_>
manveru: still wonder what planet we live on? planet of the blinds…
lorenzo__ has joined #ruby-lang
<manveru>
yorickpeterse: because it adds a dependency
<yorickpeterse>
Gemspecs already depend on the version file as it should be in the gem anyway
naz has joined #ruby-lang
<manveru>
it means you cannot look at a gemspec without having the gem itself
<apeiros_>
it's not really a spec. it's a shopping cart. once you've done the shopping, you get the spec.
Indian has joined #ruby-lang
<manveru>
:)
<manveru>
well, i'm fighting windmills anyway
<apeiros_>
s/I'm/we're/
<manveru>
aye
<yorickpeterse>
Well, I agree on the whole `git` bit but I don't see the hassle of loading version.rb
spectra has joined #ruby-lang
virunga has joined #ruby-lang
<apeiros_>
it's a bit less bad, in that it's not the same category of dependency. granted.
<yorickpeterse>
You usually don't download/use gemspecs for the version anyway, at least I don't. The only time I download them is when taking a look at dependencies and their versions of a specific project
<apeiros_>
but other than that, it's bad for the same principle.
takaokouji has joined #ruby-lang
<Spooner>
Ha, realised a circular dependency. I need my gemspec so I can use bundler in my Rakefile which makes my gemspec... :D
<Tasser>
test.rb:1:in `<main>': can't make subclass of Class (TypeError)
<Tasser>
:-(
macmartine has joined #ruby-lang
wardrop has joined #ruby-lang
slyphon has joined #ruby-lang
<whitequark>
Tasser: for what do you need that?
<Tasser>
whitequark, just tried some stuff ;-)
<whitequark>
then also try modifying singleton class of a Fixnum
<shevy>
it's how to squeeze out some more days before the FINAL DAY is coming
<shevy>
I have set out 2200 as my final year
<whitequark>
depends on what year you consider as "zero"
<shevy>
hmm
<shevy>
there were many cool years in history
<shevy>
I'd like to have seen some dinosaurs in reallife
scampbell has joined #ruby-lang
<whitequark>
depends on what do you consider "reallife"
<shevy>
and fought a sabretooth tiger with a spear and nothing but a loincloth
<whitequark>
does warcraft count? a lot will say yes
<shevy>
oh I played warcraft 3 for way too long :(
shtirlic_ has joined #ruby-lang
srbaker has joined #ruby-lang
<shevy>
I miss the insulting!
<whitequark>
try reading xda-developers
Heimidal has joined #ruby-lang
<whitequark>
it's like pouring acid in your eyes, but slightly more painful
<Tasser>
shevy, DotA ftw :D
<shevy>
Tasser yeah I never managed to get into DotA really
<Tasser>
I did :-)
<shevy>
I just always played 2 vs 2 or 3 vs 3 with tower rush. the funniest responses were always allies who cried "don't do that!"
Heimidal has joined #ruby-lang
<Tasser>
:D
<Tasser>
how can you actually beat a tower rush with nightelfes?
lordofthedance has joined #ruby-lang
<shevy>
haha
dfr|mac has joined #ruby-lang
<shevy>
usually the hero comes out about the time the towers aren't 100% finished, and they can uproot a building to fight.
apeiros_ has joined #ruby-lang
<Tasser>
let's hope your ancient of war is out at that moment...
dfr|mac_ has joined #ruby-lang
bryancp has joined #ruby-lang
<shevy>
hehe
<shevy>
I usually did not start right at the enemy base, I started in a little hidden line-of-sight area, so that it usually took them a little to realize there be towers
<apeiros_>
"there be towers" the new "there be dragons"?
<yorickpeterse>
There be arrows to the knees
<shevy>
apeiros_ kinda, but the towers look harmless compared to dragons
<shevy>
it's sneaky... until suddenly there are 3 or 5 of them and they shoot down everything nearby quickly with focused fire
<apeiros_>
you need upgrades then…
<shevy>
yeah, I liked more to play in resource control, than direct confrontation. it was a different way to think about a game, and that was more fun than to fall into "the real and only way to win" line of thinking
<shevy>
but enough off topic about that from me now!
anomnomnom has joined #ruby-lang
<anomnomnom>
hello all
<anomnomnom>
anyone alive today?
<oddmunds>
still alive
Austin__ has joined #ruby-lang
<anomnomnom>
i just had a question regarding how to approach a specific task with ruby
<anomnomnom>
is this a good place to ask... or is there another channel that would be better suited?
<rshackleford>
just ask
<anomnomnom>
nice nick there rusty.... O.o
kalleth has joined #ruby-lang
<rshackleford>
ty
joshkraemer has joined #ruby-lang
cwd1 has joined #ruby-lang
MouseTheLuckyDog has joined #ruby-lang
<anomnomnom>
ok...
<anomnomnom>
so i have what can be described as a text file
MistyM has joined #ruby-lang
<anomnomnom>
i read the text file in as a string
<anomnomnom>
err...
<anomnomnom>
maybe it would make more sense to explain the situation in its entirety
<anomnomnom>
ok... so im connecting to outlook and I am parsing email messages
yango has joined #ruby-lang
<stephenp>
i'm using DataGetStruct to wrap a custom typedef structure in a c extensions, and i always get a syntax error if i use DataGetStruct - but if I copy the actual text of the macro out of ruby.h and paste into my code, it compiles (and works) without a hitch. any idea what gives here?
<anomnomnom>
for every message i want to extract the headers and write them to a file
<anomnomnom>
but the headers are actually within the body of the email message because the messages were forwarded. what would be the best way to accomplish that?
zach_ has joined #ruby-lang
seanstickle has joined #ruby-lang
<yorickpeterse>
anomnomnom: you can try the "Mail" Gem
<anomnomnom>
sorry for the multiple line question... i will repaste my question as a single line..
<anomnomnom>
I am connecting to outlook through ruby and parsing email messages. I want to extract header information from the messages, i.e. 'from','to',subject','sent_date', etc. The problem is that the messages are forwarded, so the 'headers' are actually inside the body of the message. I already have the body of the message in a string, with "emailbody = items.getfirst.Body.to_s", so I am assuming that the best approach would be a rege
<anomnomnom>
string, but the problem is that I have to account for multiple forwards, so the headers from the original sender might be 3 or 4 "headers" down.. if that makes sense. My question is - what is the best way to approach this? Any help would be GREATLY appreciated!
dc5ala has joined #ruby-lang
<andrewvos>
TL;DR
<yorickpeterse>
As I mentioned before, take a look at Mail
<yorickpeterse>
No need for asking the same question multiple times
<yorickpeterse>
stephenp: you might want to pastie your code
<anomnomnom>
yes. i am looking at that now yorickpeterse - i just wanted to put the question together on a single line, to make it easier to understand. thank you again for the suggestion about the mail gem.
<yorickpeterse>
No need for that, if people can't read it they'll tell you so :)
<anomnomnom>
i dont think the mail gem will work for what I am trying to do... the problem isnt getting the mail necessarily, i am already able to connect to outlook and read all the messages, and get the real headers of the message. i want to scan the body text that is stored as a string in the 'emailbody' variable.
<yorickpeterse>
Mail does plain parsing as well
<yorickpeterse>
If the Emails follow the Email specification Mail can parse it most likely
virunga has joined #ruby-lang
tekin has joined #ruby-lang
<anomnomnom>
hmm.... so if they follow standard email specs.. then it will most likely have multipart components that could be parsed... something like that?
<anomnomnom>
and the 'original' message would be the last multipart in the message
<yorickpeterse>
Also, can somebody update the topic? 1.9.3-p125 was released a few days ago :)
<anomnomnom>
something like that yorick?
<yorickpeterse>
Yeah, probably
<andrewvos>
erikh: Who are you talking about?
kalleth has joined #ruby-lang
<erikh>
andrewvos: nobody
<andrewvos>
PM?
<erikh>
I'm just venting, it doesn't matter.
<anomnomnom>
is there a good way to find the last occurrence of a search pattern within a string?
<rippa>
anomnomnom: string.scan(pattern).last
<andrewvos>
Someone help me test this collabaritive code editor out!!
<andrewvos>
Any collabaritive process lasts about 3 minutes before someone breaks it for everyone else :)
<andrewvos>
Spooner: It's not mine... Was just wanting to see other people use it
<yorickpeterse>
That would be me
<andrewvos>
yorickpeterse: hahah well played
<yorickpeterse>
Hm lets see what else we can do with it
publicvoid_ has joined #ruby-lang
apeiros_ has joined #ruby-lang
apeiros_ has joined #ruby-lang
fayimora has joined #ruby-lang
wardrop has joined #ruby-lang
workmad3 has joined #ruby-lang
<andrewvos>
?
<shevy>
put them in a cage and KILL EM ALL
knicholl has joined #ruby-lang
<yorickpeterse>
Seems the editor fucked up
<andrewvos>
shevy: wrong channel bro?
<shevy>
andrewvos I am with you in the same channel. how could this be wrong when we are together? :)
<andrewvos>
hah
<any-key>
<3
<andrewvos>
Right I'm off xxx
zmack has joined #ruby-lang
jlpeters has joined #ruby-lang
wardrop has joined #ruby-lang
Dotan has joined #ruby-lang
lianj has joined #ruby-lang
lianj has joined #ruby-lang
kalleth has joined #ruby-lang
wardrop has joined #ruby-lang
tbuehlmann has joined #ruby-lang
elux has joined #ruby-lang
<elux>
hey guys
<elux>
can someone help me with some simple regexp stuff.. i dont know what im missing.. i have a string that looks like "hi there {{>partial1}} another {{>partial2}} bye" .. i am trying to match separately {{>partial1}} and {{>partial2}}
<elux>
ive tried ... .scan(/{{\s*>\s*(.*)\s*}}/)
<elux>
that will match: "{{>partial1}} another {{>partial2}} " .. but id like it to match the first case only .. or separately
<any-key>
elux: I'd recommend playing around with it on rubular.com
<elux>
yea thats what im doing.. i love that site
<elux>
but the match expression is valid... i am lost for ideas actually.. because its not hitting the first }} .. its matching the last one..
<elux>
figured it out
Natch| has joined #ruby-lang
<elux>
it was the .* that was the problem..
<any-key>
be careful with .*
<elux>
this does it: /{{\s*>\s*\S*\s*}}/
<elux>
:D
<virunga>
this /{{\s*>(\s | \S)*}}/ ??
hackeron has joined #ruby-lang
justinxreese has joined #ruby-lang
<anomnomnom>
i have a string that has multiple 'lines' of text. i am using regex to locate the 'line' that I am interested in... once i find the 'line', what is the best way to grab all the text to the 'end of line'?
achiu has joined #ruby-lang
<any-key>
anomnomnom: you can match carriage returns (\n)
<any-key>
anomnomnom: $ matches the end of a line
gasbakid__ has joined #ruby-lang
Carnage\ has joined #ruby-lang
wallerdev has joined #ruby-lang
MouseTheLuckyDog has joined #ruby-lang
<MouseTheLuckyDog>
Is there something similar to PopFile written in Ruby?
<anomnomnom>
if i have a string like "some text here\n\nFindMe: blah\nmore text here\nFindMe: junk\n\neven more text\n\n FindMe: foobar\n\nmore text\nstill more\n\n" - and I want to find the last occurence of 'FindMe:' and store everthing to the end of the line in a new variable, so $newvar = "foobar" - can someone give me some examples of how I can do that? code examples would be greatly appreciated!
<anomnomnom>
^^^does that make sense?
frem has joined #ruby-lang
<anomnomnom>
ive been struggling a bit on that one O.o
<ReinH>
str.scan(/FindMe: (.+?)\n/m).first.last
chimkan_ has joined #ruby-lang
Oloryn_lt1 has joined #ruby-lang
rshackleford has joined #ruby-lang
<apeiros_>
ReinH: hit by the crazy bug?
chessguy has joined #ruby-lang
lodbov has joined #ruby-lang
gasbakid__ has joined #ruby-lang
justinmcp has joined #ruby-lang
<anomnomnom>
ReinH: thank you. i will look at that and try it out.
* apeiros_
thinks ReinH meant .last.first
neuro_ has joined #ruby-lang
<ReinH>
apeiros_: :p
<ReinH>
apeiros_: he wants the last match
<ReinH>
just try it :p
robbyoconnor has joined #ruby-lang
* ReinH
shrugs
<ReinH>
maybe I do want last.first
<ReinH>
w/e
<apeiros_>
ReinH: :-p
<apeiros_>
I didn't read his question, only your answer. and .first.last was an expensive str[regex, 1]
hagabaka has joined #ruby-lang
hagabaka has joined #ruby-lang
Oloryn_lt1 has joined #ruby-lang
havenn has joined #ruby-lang
mikeric has joined #ruby-lang
curtism has joined #ruby-lang
curtism has joined #ruby-lang
rue has joined #ruby-lang
Tref has joined #ruby-lang
workmad3 has joined #ruby-lang
pemeon has joined #ruby-lang
Sailias has joined #ruby-lang
GiambalaGiambala has joined #ruby-lang
virunga has joined #ruby-lang
heftig has joined #ruby-lang
skryking has joined #ruby-lang
achiu has joined #ruby-lang
retro|cz has joined #ruby-lang
bglusman has joined #ruby-lang
pogopolice has joined #ruby-lang
bryancp has joined #ruby-lang
chimkan_ has joined #ruby-lang
Sailias has joined #ruby-lang
srbaker has joined #ruby-lang
workmad3 has joined #ruby-lang
gasbakid has joined #ruby-lang
mib_mib has joined #ruby-lang
pandora17 has joined #ruby-lang
lsegal has joined #ruby-lang
srbartlett has joined #ruby-lang
whatasunnyday has joined #ruby-lang
rdeshpande has joined #ruby-lang
cldwalker has joined #ruby-lang
<whatasunnyday>
.join #vimperator
heftig has joined #ruby-lang
virunga has joined #ruby-lang
Faris has joined #ruby-lang
<yorickpeterse>
whatasunnyday: IRC commands start with a /
<whatasunnyday>
yeah
<whatasunnyday>
thanks
<whatasunnyday>
i just missed it by accident
<whatasunnyday>
its set to auto join but it didn't
gregf has joined #ruby-lang
MistyM has joined #ruby-lang
dbussink has joined #ruby-lang
brianpWins has joined #ruby-lang
havenn has joined #ruby-lang
Asher has joined #ruby-lang
erpuds has joined #ruby-lang
hagebake has joined #ruby-lang
hagebake has joined #ruby-lang
hahuang65 has joined #ruby-lang
whatasunnyday has joined #ruby-lang
Swimming_Bird has joined #ruby-lang
indeterminate has joined #ruby-lang
Sailias has joined #ruby-lang
erpuds has joined #ruby-lang
phaedryx has joined #ruby-lang
phaedryx has quit [#ruby-lang]
NARKOZ has joined #ruby-lang
srbartlett has joined #ruby-lang
Indian has joined #ruby-lang
postmodern has joined #ruby-lang
slimfit has joined #ruby-lang
bglusman has joined #ruby-lang
Natch| has joined #ruby-lang
singpolyma has joined #ruby-lang
bosie has joined #ruby-lang
<bosie>
if i get an error "require no such file to load -- foo", how do i solve this problem? if i uses absolute path it works
<injekt>
bosie: the cwd is not in the load path
<bosie>
injekt: if i go to the top of my file and say Dir.getwd it actually points to the correct dir
<injekt>
so you need to either use `require_relative 'foo'` or 'require File.expand_path('../foo', __FILE__)' or require './foo'
* apeiros_
sobs
* apeiros_
decides not to care
<bosie>
injekt: ok, i am doing the __FILE__ thing, but figured there would be better ways to do it
<injekt>
there are
<mib_mib>
How do i translate this php line into Ruby using the OAuth Gem? I cant find the right function: $oauth->fetch(http://www.example.com/oauth_url, array('xoauth_oauth2_access_token' => 'some_access_token'), OAUTH_HTTP_METHOD_POST);
<injekt>
require_relative is there for a reason
<bosie>
injekt: lemme try
<bosie>
injekt: that actually worked
<injekt>
you seem surprised
<bosie>
absolutely not, you are the king ;)
<injekt>
lol, no i just read my ruby docs :)
<bosie>
injekt: i have to say... i stopped with 1.8 ... just recently came back to ruby. guess i have to re-study the api ;)
<injekt>
well, pre 1.8.7 $LOAD_PATH included '.', but now it doesn't :)
looopy has joined #ruby-lang
<bosie>
ah
<bosie>
ok
<bosie>
and i blamed rubymine
<bosie>
;)
<bosie>
thanks
<injekt>
eek
<bosie>
eek?
<injekt>
yes, rubymind, EEEKK
<injekt>
rubymine*
<bosie>
why?
<injekt>
it's, not to my taste :)
<bosie>
ah yea. used textmate and vim for years, dunno.
<injekt>
you used vim for years and you're now using rubymine?
<injekt>
not often that happens
<bosie>
ye
<bosie>
did java for 2 years using intellij idea. got my taste for IDEs back ;)
<injekt>
ahh
eggman2001 has joined #ruby-lang
<injekt>
intellij is pretty nice
ajsie has joined #ruby-lang
<injekt>
I do lots of java still, and I do use an IDE for that
ajsie has quit [#ruby-lang]
<bosie>
what you using if you don't do java
<injekt>
vim
<bosie>
ah
<injekt>
or textmate sometimes
<bosie>
interesting
<bosie>
whats your setup?
<bosie>
the lack of proper folding, completion, navigation etc drove me nuts
<bosie>
injekt: sure, i found screenshots of conque
herpless has joined #ruby-lang
<rue>
Rorr
<rue>
bosie: You can also do :!mkdir blah &
<bosie>
rue: sure
twittard has joined #ruby-lang
<eggman2001>
is there a more elegant way to write 'if !(false); do this; end'
<eggman2001>
specifically the if !(false) part
<herpless>
i'm pretty new to ruby too, but I think: unless false ...
<apeiros_>
do this unless false
<eggman2001>
ah okay, thanks
Jay_Levitt has joined #ruby-lang
wmoxam_ has joined #ruby-lang
WillMarshall has joined #ruby-lang
<drbrain>
herpless: I write "this unless false" if it's short enough
<drbrain>
I guess "do_this unless false" would be clearer
kyrylo_ has joined #ruby-lang
kyrylo_ has joined #ruby-lang
shevy2 has joined #ruby-lang
fayimora has joined #ruby-lang
andrewhl has joined #ruby-lang
pabloh has joined #ruby-lang
wmoxam has joined #ruby-lang
herpless has joined #ruby-lang
fernicle has joined #ruby-lang
frequency9 has joined #ruby-lang
havenn has joined #ruby-lang
<eggman2001>
I'm having trouble tracking down the source of a NoMethodError. does anyone know of a way for me to pinpoint this without having to break up my code into pieces?
<hagebake>
what's the entire error message?
<eggman2001>
NoMethodError: undefined method `my_method' for nil:NilClass
<eggman2001>
I know what it means. just having trouble tracking down the code that's causing it
<hagebake>
it should show a filename and line number, and a caller method
<eggman2001>
it looks like this: NoMethodError: undefined method `my_method' for nil:NilClass
<eggman2001>
from /home/user/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/whiny_nil.rb:48:in `method_missing'
<erikh>
keep looking backwards
<erikh>
until you're in your code
<fernicle>
Maybe try appending `unless whatever.youre.calling.blank?` to the end of the line?
<eggman2001>
erikh: what do you mean by keep looking backwards?
<erikh>
eggman2001: you should have a rather long stack trace there
<erikh>
especially because it's rails code
<injekt>
yeah
<eggman2001>
i've got no stack trace. not sure if it's because I'm running the command in pry
<erikh>
from the top down, you'll be working backwards on what's called the "call stack" to see what got called and where it got called to lead to the error
<injekt>
eggman2001: when are you getting that error? when you load a specific page?
<eggman2001>
i'm not loading a page. i'm running a method in pry
<erikh>
can you give us a paste of what you're trying to do?
<injekt>
pry + active support
<injekt>
im out
<erikh>
like, just paste out of the terminal to gist.github.com or something
<erikh>
injekt: yeah, magic central
<eggman2001>
injekt: what do you mean?
<eggman2001>
erikh: there's nothing that useful in the output unfortunately. just many lines of sql
<injekt>
eggman2001: I mean there's too much magical stuff going on
<erikh>
well then I can't help you
<injekt>
eggman2001: there's always something useful in the output
<injekt>
paste it
<injekt>
maybe you're missing something and need an extra pair of eyes
<injekt>
or maybe you're right and there's nothing that'll help you in the output, but how will you know if you're the only one looking at it :)