Skip to content

Commit 9c1c747

Browse files
committed
Modiefies text to address specifics of Ruby naming convetions instead of Python.
1 parent b086bc6 commit 9c1c747

File tree

9 files changed

+126
-108
lines changed

9 files changed

+126
-108
lines changed

ruby/README.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
# Python Naming Convention
1+
# Ruby Naming Convention
22

3-
The style guide for Python is based on [Guido’s ](https://www.python.org/doc/essays/styleguide/)naming convention recommendations.
3+
The style guide for Ruby is based on [Guido’s ](https://www.Ruby.org/doc/essays/styleguide/)naming convention recommendations.
44

55
List of covered sections:
66

7-
* [Class Naming](../python/class-naming.md)
8-
* [Constant Naming](../python/constant-naming.md)
9-
* [Method Naming](../python/method-naming.md)
10-
* [Module Naming](../python/module-naming.md)
11-
* [Variable Naming](../python/variable-naming.md)
12-
* [Package Naming](../python/package-naming.md "Python Package Naming")
13-
* [Exception Naming](../python/exception-naming.md)
14-
* [Underscore](../python/underscore.md)
7+
* [Class Naming](../Ruby/class-naming.md)
8+
* [Constant Naming](../Ruby/constant-naming.md)
9+
* [Module Naming](../Ruby/file-naming.md)
10+
* [Method Naming](../Ruby/method-naming.md)
11+
* [Package Naming](../Ruby/module-naming.md)
12+
* [Variable Naming](../Ruby/variable-naming.md)
1513

1614
#### TL;DR
1715

18-
| Type | Public | Internal |
19-
| :--- | :--- | :--- |
20-
| Packages | `lower_with_under` | |
21-
| Modules | `lower_with_under` | `_lower_with_under` |
22-
| Classes | `CapWords` | `_CapWords` |
23-
| Exceptions | `CapWords` | |
24-
| Functions | `lower_with_under()` | `_lower_with_under()` |
25-
| Global/Class Constants | `CAPS_WITH_UNDER` | `_CAPS_WITH_UNDER` |
26-
| Global/Class Variables | `lower_with_under` | `_lower_with_under` |
27-
| Instance Variables | `lower_with_under` | `_lower_with_under` |
28-
| Method Names | `lower_with_under()` | `_lower_with_under()` |
29-
| Function/Method Parameters | `lower_with_under` | |
30-
| Local Variables | `lower_with_under` | |
16+
| Type | Convention |
17+
| :--- | :--- |
18+
| Files | `lower_with_under` |
19+
| Modules | `CapWords`|
20+
| Classes | `CapWords` |
21+
| Functions | `lower_with_under()` |
22+
| Global/Class Constants | `CAPS_WITH_UNDER` |
23+
| Global/Class Variables | `lower_with_under` |
24+
| Instance Variables | `lower_with_under` |
25+
| Method Names | `lower_with_under()` |
26+
| Function/Method Parameters | `lower_with_under` |
27+
| Local Variables | `lower_with_under` |
3128

3229
Missing something? Please contribute here by reading [this guide](../docs/CONTRIBUTING.md).
33-

ruby/class-naming.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
<<<<<<< Updated upstream
12
# Python Naming Convention > Class Naming
3+
=======
4+
# Ruby Naming Convention > Class Naming
5+
>>>>>>> Stashed changes
26
37
## PascalCase
48

59
* Begin with an uppercase letter
610
* Preferably a noun e.g. Car, Bird, MountainBike
711
* Avoid acronyms and abbreviations
812

13+
<<<<<<< Updated upstream
914
```python
1015
class Car:
1116
...
@@ -25,3 +30,9 @@ class _Car: # private class
2530

2631

2732

33+
=======
34+
```ruby
35+
class Car
36+
...
37+
```
38+
>>>>>>> Stashed changes

ruby/constant-naming.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1+
<<<<<<< Updated upstream
12
# Python Naming Convention > Constant Naming
3+
=======
4+
# Ruby Naming Convention > Constant Naming
5+
>>>>>>> Stashed changes
26
37
## SCREAMING_SNAKE_CASE
48

59
* Should be all uppercase letters e.g. AGE, HEIGHT
610
* If the name contains multiple words, it should be separated by underscores (_) such as DAYS_IN_MONTH
711
* May contain digits but not as the first letter
812

13+
<<<<<<< Updated upstream
914
```python
1015
class Product:
1116
MAX_TEMPERATURE = 36;
1217
```
1318

1419

1520

21+
=======
22+
```ruby
23+
class Product
24+
MAX_TEMPERATURE = 36;
25+
```
26+
>>>>>>> Stashed changes

ruby/exception-naming.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

ruby/file-naming.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
<<<<<<< Updated upstream
12
# Python module Convention > Package Naming
3+
=======
4+
# Ruby module Convention > File Naming
5+
>>>>>>> Stashed changes
26
37
## snake_case
48

59
* Should be in lowercase.
610
* If the name contains multiple words, an underscore (_) should separate it.E.g. expression_engine
711
* The name should resonate with the class or methods inside the module
812

13+
<<<<<<< Updated upstream
914
```python
1015
from math import factorial
1116
class Car:
@@ -14,3 +19,10 @@ class Car:
1419

1520

1621

22+
=======
23+
```ruby
24+
require './application_record'
25+
class Car
26+
...
27+
```
28+
>>>>>>> Stashed changes

ruby/method-naming.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
<<<<<<< Updated upstream
12
# Python Naming Convention > Method Naming
3+
=======
4+
# Ruby Naming Convention > Method Naming
5+
>>>>>>> Stashed changes
26
37
## snake_case
48

59
* Should be all in lowercase
610
* Preferably a verb e.g. get_car(), purchase(), book()
711
* If the name contains multiple words, it should be separated by underscores \(\_\) e.g. get\_json\(\)
12+
<<<<<<< Updated upstream
813

914
```python
1015
class Person:
@@ -28,3 +33,36 @@ class Person:
2833

2934

3035

36+
=======
37+
* Clear and descriptive method names without abbreviations are preferred.
38+
39+
```ruby
40+
class Person
41+
def get_height(self)
42+
return self.height
43+
end
44+
end
45+
```
46+
47+
## Private methods
48+
49+
To make a method private, use the keyword `private` above it anywhere in the class.
50+
51+
```ruby
52+
class Person
53+
54+
def get_height(self)
55+
return self.height
56+
end
57+
58+
private
59+
60+
def get_weight(self)
61+
return self.height
62+
end
63+
64+
end
65+
```
66+
67+
Above, `get_height()` is public, `get_weight()` is private. You may use the `public` key word below `private`, but generally this is not done.
68+
>>>>>>> Stashed changes

ruby/module-naming.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Python module Convention > Module Naming
1+
# Ruby Naming Convention > Module Naming
22

3-
## snake_case
4-
- Should be all in lowercase letters such as requests, math
5-
- If contains multiple words, it should be separated by underscores (_) e.g. expression_engine.py
6-
- Should resonate with the class or methods inside the module
3+
## PascalCase
4+
- Adjoining capitalized words
5+
- Should resonate with the classes or methods inside the module
76

8-
```python
9-
from math import factorial
10-
class Car:
11-
...
7+
```ruby
8+
9+
module ApplicationHelper
10+
end
1211
```

ruby/underscore.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

ruby/variable-naming.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
<<<<<<< Updated upstream
12
# Python Naming Convention > Variable Naming
3+
=======
4+
# Ruby Naming Convention > Variable Naming
5+
>>>>>>> Stashed changes
26
37
## snake_case
48

59
* Should be all in lowercase
610
* Not begin with the special characters like e.g. & (ampersand), $ (dollar)
711
* If the name contains multiple words, it should be separated by underscores (_) e.g. json_string
812
* Avoid one-character variables e.g. a, b
13+
<<<<<<< Updated upstream
914

1015
```python
1116
class Student
@@ -29,3 +34,24 @@ class Student:
2934

3035

3136

37+
=======
38+
* Clear and descriptive variable names without abbreviations are preferred.
39+
40+
```ruby
41+
first_name = "Hanz"
42+
```
43+
44+
The above is an example of a local variable.
45+
46+
Instance variables are prefixed with an '@' and are used in Ruby classes as show below.
47+
48+
49+
```ruby
50+
class Student
51+
def initialize(name)
52+
@name = name
53+
end
54+
```
55+
56+
Other prefixes include '$' for global variables, and '@@' for class variables. But when possible, instance and local variables are preferred.
57+
>>>>>>> Stashed changes

0 commit comments

Comments
 (0)