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.0309 sec