- RubyLanguage
- RubyLanguage/Class
- RubyLanguage/Container
- RubyLanguage/ExceptionHandling
- RubyLanguage/InputOutput
3. ๋ชจ๋ ¶
- ์ธ์คํด์คํ ํ ์ ์๋ ํด๋์ค
- Class ํด๋์ค๋ Module ํด๋์ค์ ์๋ธ ํด๋์ค
- ํด๋์ค = ๋ชจ๋ + ์ธ์คํด์คํ ๋ฅ๋ ฅ
- ํด๋์ค = ๋ชจ๋ + ์ธ์คํด์คํ ๋ฅ๋ ฅ
- ๊ธฐ๋ฅ
- Mix-in
- Namespace
- Mix-in
3.1. Mix-in ¶
- ์ ํ๋ ๋ค์ค์์
- Ruby๋ ๋จ์ผ์์๋ง์ ์ง์ํ๋ค.
- ๋ฐ๋ผ์ ํด๋์ค๋ ํ๋๋ง ์์ํ ์ ์๋ค.
- ๊ทธ๋ฌ๋ ๋ชจ๋์ ์ฌ๋ฌ๊ฐ๋ฅผ ์์๋ฐ์ ์ ์๋ค.
- ๋ฐ๋ผ์ ํด๋์ค๋ ํ๋๋ง ์์ํ ์ ์๋ค.
- Ruby๋ ๋จ์ผ์์๋ง์ ์ง์ํ๋ค.
- Include : ํด๋์ค๊ฐ ๋ชจ๋์ ์์๋ฐ๋ ๊ฒ.
3.2. Namespace ¶
// 1 class Service end // 2 module Library class Service end end
- ์์ Service ํด๋์ค๋ ์ต์์ ๋ ๋ฒจ์ namespace์ ์ํด ์๊ณ , ๋ค์ Service ํด๋์ค๋ Library ๋ชจ๋์ ์ํด ์๋ค.
1์ ๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ ์ ์๋ค.
Service๋๋
::Service
2 ๋ ๋ค์๊ณผ ๊ฐ๋ค.
Library::Service