U E D R , A S I H C RSS

Ruby Language/Class


1. ํด๋ž˜์Šค

2. ๋ณ€์ˆ˜์™€ ์ƒ์ˆ˜

3. ๋ชจ๋“ˆ

  • ์ธ์Šคํ„ด์Šคํ™” ํ•  ์ˆ˜ ์—†๋Š” ํด๋ž˜์Šค
  • Class ํด๋ž˜์Šค๋Š” Module ํด๋ž˜์Šค์˜ ์„œ๋ธŒ ํด๋ž˜์Šค
    • ํด๋ž˜์Šค = ๋ชจ๋“ˆ + ์ธ์Šคํ„ด์Šคํ™” ๋Šฅ๋ ฅ
  • ๊ธฐ๋Šฅ
    • Mix-in
    • Namespace

3.1. Mix-in

  • ์ œํ•œ๋œ ๋‹ค์ค‘์ƒ์†
    • 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
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:27:56
Processing time 0.0183 sec