Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I capitalize Ruby? [closed]

RUBY? Ruby? ruby? What's good style?

I know the answer—I just wanted to make sure the question was out there and questioners were aware that there is a correct form.

Also, should I capitalize "gem" as "GEM"?

class TestLanguageName < Test::Unit::TestCase
  def test_language_name
    assert_correct_language_name StackOverflow.new.describe_language("RuBy")
  end
end

class StackOverflow
  def describe_language(string)
    # Which of the following?
    methods = [:upcase, :capitalize, :downcase]
    string.send(methods[rand(3)])
  end
end
like image 378
Andrew Grimm Avatar asked May 19 '11 02:05

Andrew Grimm


People also ask

How do you capitalize in Ruby?

Ruby | String capitalize() Methodcapitalize is a String class method in Ruby which is used to return a copy of the given string by converting its first character uppercase and the remaining to lowercase. Parameters: Here, str is the given string which is to be converted.

How to make the first letter of a String uppercase in Ruby?

Use capitalize . From the String documentation: Returns a copy of str with the first character converted to uppercase and the remainder to lowercase.


1 Answers

Section 1.9 of ruby-doc.org FAQ says:

Officially, the language is called "Ruby". On most systems, it is invoked using the command "ruby". It's OK to use ruby instead of Ruby. Please don't use RUBY as the language name. Originally, or historically, it was called "ruby".

Either Ruby or ruby is correct.

like image 58
sawa Avatar answered Sep 22 '22 15:09

sawa