[Ruby] Object-oriented programming terminology

less than 1 minute read

class

・ Data type
-Alias: “Object blueprint” “Object template”
-If the class is the same, the attributes (data items) held and the methods that can be used are the same.

Objects, instances, receivers

・ A chunk of data created based on a class
-When explaining the relationship with a method, it is sometimes called a receiver.

python


food = Food.new('apple', '7:00')
food.name

This code may be described as:
“The second line calls the name method of the Food object.”
“The receiver for the name method here is food.”

Method, message

-A group of processes with a name.

python


food = Food.new('apple', '7:00')
food.name

“The second line sends the message name to the receiver called food.”

State

-Data held for each object
-Data such as “name” and “age” of the Food class is also included in the “Food status”.

Attributes (attributes, properties)

-A value that can be obtained from an object

python


food = Food.new('apple', '7:00')
food.name = 'apple'

reference
An introduction to Ruby for those who want to become professionals

Tags:

Updated: