Ruby Coding Style
2015-09-19 17:07:37
2011-03-02 16:14:09
Autor: Sony Santos
https://gigawiki.com/sony/ruby-coding-style
Permalink: https://gigawiki.com/959
assunto = ruby; categ = links; language = English
https://github.com/chneukirchen/styleguide/blob/master/RUBY-STYLE
https://github.com/bbatsov/ruby-style-guide#source-code-layout
http://www.pathf.com/blogs/ruby-and-rails-style-guide/
http://www.caliban.org/ruby/rubyguide.shtml (includes other interesting practical introductory tips on Ruby)

From above link about Naming:
Avoid single character variable names for anything except counters and iterators.

The standard Ruby file extension is .rb, although many people working on UNIX-like systems don't bother with it for stand-alone scripts. Whether or not you use it for scripts is up to you, but you will need to use it for library files or they will not be found by the interpreter.

Class and module names should be in camel-case, e.g:

Class BigFatObject

Class names should be nouns. In the case of modules, it's harder to make a clear recommendation. The names of mix-ins (which are just modules) should, however, probably be adjectives, such as the standard Enumerable and Comparable modules.

Constants should be named using all upper-case characters and underscores, e.g.

BigFatObject::MAX_SIZE

They should also be nouns.

Method names should be named using all lower-case characters and underscores. If possible, the name should be a verb, e.g.

BigFatObject#pare_down

Variable names should be named using all lower-case characters and underscores, but unlike method names, try to pick nouns, e.g. size. This applies to local, global, instance and class variables alike. However, there's a case to be made for keeping the names of local variables shorter than those of variables that will be made externally available, such as instance variables. For example, you might want to use resp_code as a local variable, but @response_code as an instance variable.
blog comments powered by Disqus