Aligning Case with When and Else

Hi,

I'd like to set up RubyMine to line up my case statements as follows by default, but I don't know how.

# Determine US generation name based on birth year
# Case expression tests ranges with ===
generation = case birthyear
                   when 1946..1963: "Baby Boomer"
                   when 1964..1976: "Generation X"
                   when 1978..2000: "Generation Y"
                   else nil
                   end

Thank you. :)

3 comments
Comment actions Permalink

Go to File|Settings|Code Style|Ruby, select "Other" tab and uncheck "indent when case".

Hope this helps, Oleg.

0
Comment actions Permalink

Sory for bumping old subject. But I have a question: why this option checked by default?
In https://github.com/bbatsov/ruby-style-guide

Indent when as deep as case. I know that many would disagree with this one, but it's the style established in both "The Ruby Programming Language" and "Programming Ruby".

And https://github.com/styleguide/ruby says the same.

Is ruby mine not folloy style-guide or this guides not authoritative?

0
Comment actions Permalink

I think the only reason is that the default setting for this option was selected before the guide.
And after that nobody actually care to report this problem to us :( All-in-all it is just one time change if you want to follow the guide ;)
I'd suggest you to file a ticket about this in our tracker (http://youtrack.jetbrains.com/issues/RUBY) and we will change the setting.

Oleg.

0

Please sign in to leave a comment.