[#386100] Numeric#coerce docs are disaster — 7stud -- <bbxx789_05ss@...>

num.coerce(numeric) =E2=86=92 array

14 messages 2011/08/02

[#386114] Documentation Improvement Proposal — Chris White <cwprogram@...>

=3D Issues =3D

24 messages 2011/08/02
[#386115] Re: Documentation Improvement Proposal — Steve Klabnik <steve@...> 2011/08/02

I reeeeeealy dislike user comments on documentation. It's one of the

[#386117] Re: Documentation Improvement Proposal — Phillip Gawlowski <cmdjackryan@...> 2011/08/02

On Tue, Aug 2, 2011 at 7:39 PM, Steve Klabnik <steve@steveklabnik.com> wrot=

[#386118] Re: Documentation Improvement Proposal — Steve Klabnik <steve@...> 2011/08/02

> What's wrong with stealing WikiPedia's procedures? The model works

[#386119] Re: Documentation Improvement Proposal — Chris White <cwprogram@...> 2011/08/02

On Aug 2, 2011, at 11:00 AM, Steve Klabnik wrote:

[#386123] Re: Documentation Improvement Proposal — Steve Klabnik <steve@...> 2011/08/02

Apologies, I've just responded to everyone in-line.

[#386231] Brainstorming ideas how to improve Ruby's documentation — Marc Heiler <shevegen@...>

The title is misleading...

42 messages 2011/08/05
[#386233] Re: Brainstorming ideas how to improve Ruby's documentation — "Fred L." <f.linard@...> 2011/08/05

Hello,

[#386235] Re: Brainstorming ideas how to improve Ruby's documentation — Alexander Litvinovsky <alexander.litvinovsky@...> 2011/08/05

What are you talking about? Ruby has a nice docs, railsapi.com for example.

[#386297] Help out with the next version of ruby-lang.org — Magnus Holm <judofyr@...>

https://github.com/rubylang/ruby-lang.org

11 messages 2011/08/07

[#386341] Exceptional Ruby and Metaprogramming Ruby has anyone picked these up? — Kevin <darkintent@...>

I'm thinking of picking up these two books and was wondering if anyone

11 messages 2011/08/09

[#386378] ruby installation — "Momodou J." <modou75alieu@...>

how to implement this in windows :

16 messages 2011/08/09

[#386401] *WHY* does this not work? — serialhex <serialhex@...>

ok, so code:

23 messages 2011/08/09
[#386403] Re: *WHY* does this not work? — "Darryl L. Pierce" <mcpierce@...> 2011/08/09

On Wed, Aug 10, 2011 at 03:52:59AM +0900, serialhex wrote:

[#386404] Re: *WHY* does this not work? — serialhex <serialhex@...> 2011/08/09

On Tue, Aug 9, 2011 at 3:05 PM, Darryl L. Pierce <mcpierce@gmail.com> wrote:

[#386480] Odd regexp behavior — Glen Holcomb <damnbigman@...>

I'm running 1.9.2-p180

16 messages 2011/08/10

[#386506] Distributing Ruby program as a standalone executable (exe) for windows — Michelle Pace <michelle@...>

Hello there,

10 messages 2011/08/11

[#386539] Online tutor for Ruby — T J Pereira <tj5155@...>

I am finding it difficult to apply the RUBY program. Its because i have

18 messages 2011/08/12
[#386541] Re: Online tutor for Ruby — Phillip Gawlowski <cmdjackryan@...> 2011/08/12

On Fri, Aug 12, 2011 at 6:00 AM, T J Pereira <tj5155@tm.net.my> wrote:

[#386637] class inheritance and class constants — Iñaki Baz Castillo <ibc@...>

------------------------

16 messages 2011/08/14

[#386784] Green Shoes v1.0 released — ashbb <ashbbb@...>

Hello, everyone.

15 messages 2011/08/18
[#392062] Re: Green Shoes v1.0 released — Barry Yu <yubarry@...> 2012/01/09

why do I get this error?

[#386796] Searching in a directory — Yu Yu <htwoo@...>

Hello,

21 messages 2011/08/18

[#386893] Gritty Details of super() — luke gruber <luke.gru@...>

Hey guys,

18 messages 2011/08/21

[#386900] Possble bug in Ruby parser (Fixnum#times within "case" statement) — Iñaki Baz Castillo <ibc@...>

Hi, I cannot find an explanation for the following issue so I think it's a =

15 messages 2011/08/21
[#386901] Re: Possble bug in Ruby parser (Fixnum#times within "case" statement) — Ryan Davis <ryand-ruby@...> 2011/08/21

[#386903] Re: Possble bug in Ruby parser (Fixnum#times within "case" statement) — Iñaki Baz Castillo <ibc@...> 2011/08/21

2011/8/22 Ryan Davis <ryand-ruby@zenspider.com>:

[#386920] New to Ruby some problems — jack jones <shehio_22@...>

I am new to Ruby, My mother tongue is C++ .. I have too many problems I

21 messages 2011/08/22

[#386949] Want to get involved with this doc stuff? I'm making it even easier — Steve Klabnik <steve@...>

Hey guys-

9 messages 2011/08/22

[#387058] How the access the values of this result — QAS WM <qaiserwali@...>

I am getting the following as a result of a script I run.

11 messages 2011/08/26

[#387070] overloading methods question please? — jack jones <shehio_22@...>

def do_something(a as Array)

11 messages 2011/08/26

[#387138] String#split resets regex captures variables (Ruby 1.8.7) — Olivier Lance <bestiol@...>

Hi,

10 messages 2011/08/29

[#387196] SAMSUNG to produce "Ruby on Rails in Silicon" System on a Chip — Ilias Lazaridis <ilias@...>

(public draft)

9 messages 2011/08/31

[#387197] Prepend a character to a string in ruby — ruby rails <rubyonrails4me@...>

Hi,

10 messages 2011/08/31

[#387212] GUI programming — Samuel Mensah <sasogeek@...>

Is ruby GUI programming something that will come along as I study ruby

19 messages 2011/08/31
[#387230] Re: GUI programming — Alexey Petrushin <axyd80@...> 2011/08/31

I believe right now it's better to stay with console, there's no Ruby

Re: *WHY* does this not work?

From: Florian Gilcher <flo@...>
Date: 2011-08-09 20:02:02 UTC
List: ruby-talk #386418
It depends on two things: whether you want to preserve the input lines =
or not.

First of all, I would do such stuff in a function that takes an =
argument. It keeps
you from being dependent on an instance variable. So I will use:

    def strip_python_loads(input)

This makes the code usable in more contexts.

Now, if you don't care about preserving line numbers, you can do the =
following:

    text =3D <<PYTHON
    from foo import bar

    batz
    PYTHON

    def strip_python_loads(input)
      input.reject { |line| line =3D~ /\s*from[ =
A-Za-z0-9\_.]*import\s*\w*/ }=20
      # or reject! if you want to destruct input
    end

    puts strip_python_loads(text.split("\n")).join("\n")

Preserving input can be done using #map:

    text =3D <<PYTHON
    from foo import bar

    batz
    PYTHON

    def strip_python_loads(input)
      input.map do |line|
        unless line =3D~ /\s*from[ A-Za-z0-9\_.]*import\s*\w*/
          line
        end
      end
      #same here, #map! works destructively
    end

    puts strip_python_loads(text.split("\n")).join("\n")
    # or even
    puts strip_python_loads(text.lines).join("\n")

Regards,
Florian


On Aug 9, 2011, at 9:38 PM, serialhex wrote:

> ok, many responses, all very good and reasonable, but i guess my point =
is
> kinda missed so i'll explain deeper...
>=20
> here is an awesome kludge of a program i wrote last night:
> https://gist.github.com/1133359
>=20
> yes it's ugly, and yes it's horrible, but it's not meant to be used =
for
> anything more than what it was used for (which is quickly converting =
python
> to ruby, and give kinda workable results most of the time, and since =
it's
> simply single file programs that i was going to edit & fix later, i'm =
not
> worried as to how ugly the translator is, or the translation, it just =
did
> 90% of my work for me)
>=20
> look at the strip_python_loads method, that is the *best* way i can =
come up
> with at the moment.  yes i know there are better ways (to write this =
and the
> entire program) but what are they?  if i wanted to edit the contents =
of an
> array while iterating through it how do it do it besides that?  like i =
said,
> a method such as each! which will allow you to modify the receiver =
would be
> nice...
> hex
>=20
> p.s. oh, and if you want to fork & edit that gist to make it prettier =
& more
> useful feel free to do so!
>=20
>=20
> --=20
> my blog is cooler than yours: serialhex.github.com
>=20
> The wise man said: "Never argue with an idiot. They bring you down to =
their
> level and beat you with experience."
>=20
>>> Other than the fact Linux has a cool name, could someone explain why =
I
>>> should use Linux over BSD?
>>=20
>> No.  That's it.  The cool name, that is.  We worked very hard on
>> creating a name that would appeal to the majority of people, and it
>> certainly paid off: thousands of people are using linux just to be =
able
>> to say "OS/2? Hah.  I've got Linux.  What a cool name".  386BSD made =
the
>> mistake of putting a lot of numbers and weird abbreviations into the
>> name, and is scaring away a lot of people just because it sounds too
>> technical.
> 	-- Linus Torvalds' follow-up to a question about Linux

--
Florian Gilcher

smtp:   flo@andersground.net
jabber: Skade@jabber.ccc.de
gpg:    533148E2


In This Thread