{"id":248,"date":"2013-12-16T03:18:16","date_gmt":"2013-12-15T18:18:16","guid":{"rendered":"http:\/\/www.uturtle.com\/blog\/?p=248"},"modified":"2013-12-18T20:16:48","modified_gmt":"2013-12-18T11:16:48","slug":"ruby-%ec%96%b8%ec%96%b4-%ec%a0%95%eb%a6%ac-3","status":"publish","type":"post","link":"https:\/\/www.jinukbaek.com\/blog\/ko\/archives\/248","title":{"rendered":"Ruby \uc5b8\uc5b4 \uc815\ub9ac (3)"},"content":{"rendered":"<h1>\ub8e8\ube44(Ruby)\uc5b8\uc5b4 \uc815\ub9ac<\/h1>\n<p>\uc18c\uc2a4\ucf54\ub4dc\ub97c \ud1b5\ud558\uc5ec \uc8fc\uc694\ud55c \uae30\ub2a5\ub9cc \ud655\uc778\ud574\ubcf4\uace0 \ub118\uc5b4\uac04\ub2e4.<\/p>\n<h2>\ud074\ub798\uc2a4\uc640 \uac1d\uccb4<\/h2>\n<pre class=\"lang:ruby decode:true\"><code>class Car\r\n    @@run_car = 0  # \ud074\ub798\uc2a4 \ubcc0\uc218 \/ static \ubcc0\uc218\r\n\r\n    attr_reader :pos    # \uc77d\uae30 \uc804\uc6a9 \uc18d\uc131(attribute)\r\n    attr_writer :pos    # \uc4f0\uae30 \uc804\uc6a9 \uc18d\uc131\r\n    attr_accessor :light # \uc77d\uae30\/\uc4f0\uae30 \uac00\ub2a5 \uc18d\uc131\r\n\r\n    def initialize(color) # \uc0dd\uc131\uc790\r\n        @color = color  # @\ub294 \uba64\ubc84\ubcc0\uc218 \uc5c6\ub294 \uac83\uc740 \uc9c0\uc5ed\ubcc0\uc218\r\n    end\r\n\r\n    def get_color\r\n        return @color\r\n    end\r\n\r\n    def get_run_car\r\n        return @@run_car\r\n    end\r\n\r\n    def Car.run(num)  # \ud074\ub798\uc2a4 \uba54\uc18c\ub4dc | static \ud568\uc218\r\n        @@run_car += num\r\n    end\r\n\r\n    def id_car()  # id_car\uac12 \ubc18\ud658 \uc811\uadfc\uc790 \uba54\uc18c\ub4dc\r\n        @id_car\r\n    end\r\n\r\n    def id_car=(id_car)  # pos\uac12 \uc4f0\uae30 \uc811\uadfc\uc790 \uba54\uc18c\ub4dc\r\n        @id_car = id_car\r\n    end\r\n\r\nprotected # \uba54\uc18c\ub4dc \uacf5\uac1c \ubc94\uc704 (JAVA\uc640 \uac19\uc74c)\r\n    def alaram\r\n    end\r\n\r\nprivate # \uba54\uc18c\ub4dc \uacf5\uac1c \ubc94\uc704 (JAVA\uc640 \uac19\uc74c)\r\n    def check \r\n    end\r\nend\r\n\r\nclass SuperCar &lt; Car   # \uc0c1\uc18d\r\n   def initialize(color)\r\n       super(color)  # \ubd80\ubaa8 \uc0dd\uc131\uc790 \ud638\ucd9c\r\n   end\r\n\r\n   def get_color\r\n       return \"red\"\r\n   end\r\nend\r\n\r\nsupercar = SuperCar.new(\"blue\") # \uc778\uc2a4\ud134\uc2a4 \uc0dd\uc131\r\nCar.run(100) # \ud074\ub798\uc2a4 \uba54\uc18c\ub4dc \ud638\ucd9c \r\n<\/code><\/pre>\n<h2>\ubaa8\ub4c8<\/h2>\n<pre class=\"lang:ruby decode:true\"><code>module Computer\r\n    def Computer.buy(com)\r\n        puts com + \" buy\"\r\n    end\r\n\r\n    class CPU\r\n        def CPU.run\r\n            puts cpu + \" run\"\r\n        end\r\n    end\r\nend\r\n\r\ninclude \"computer.pb\" # \uc678\ubd80 \ub8e8\ube44 \ud30c\uc77c \uc785\ud3ec\ud2b8\r\nComputer.buy \"Alpha\"\r\nComputer::CPU.run   # module\uc758 class\ub294 ::\uc744 \uc774\uc6a9\ud558\uc5ec \uc811\uadfc\ud55c\ub2e4.\r\n\r\n<\/code><\/pre>\n<h2>\ubaa8\ub4c8 \ud63c\ud569<\/h2>\n<pre class=\"lang:ruby decode:true\"><code>module LeftClick\r\n    def lclick\r\n        puts \"Left Clicked\"\r\n    end\r\nend\r\n\r\nmodule RightClick\r\n    def rclick\r\n        puts \"Right Clicked\"\r\n    end\r\nend \r\n\r\nclass Mouse\r\n    include LeftClick\r\n    include RightClick\r\nend\r\n\r\nmouse = Mouse.new() # Mouse\ub294 LeftClick, RightClick 2\uac00\uc9c0 \uae30\ub2a5\uc774 \ud63c\ud569\ub41c\ub2e4. (\ub2e4\uc911\uc0c1\uc18d), Module\uc740 \uc778\uc2a4\ud134\uc2a4 \uc0dd\uc131\uc774 \ubd88\uac00\ud558\ub098 Mouse\ub294 class\uc774\ubbc0\ub85c \uac00\ub2a5\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ub8e8\ube44(Ruby)\uc5b8\uc5b4 \uc815\ub9ac \uc18c\uc2a4\ucf54\ub4dc\ub97c \ud1b5\ud558\uc5ec \uc8fc\uc694\ud55c \uae30\ub2a5\ub9cc \ud655\uc778\ud574\ubcf4\uace0 \ub118\uc5b4\uac04\ub2e4. \ud074\ub798\uc2a4\uc640 \uac1d\uccb4 class Car @@run_car = 0 # \ud074\ub798\uc2a4 \ubcc0\uc218<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[135],"tags":[117],"class_list":["post-248","post","type-post","status-publish","format-standard","hentry","category-ruby-on-rails","tag-ruby-language"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8gT1J-40","_links":{"self":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/comments?post=248"}],"version-history":[{"count":2,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/248\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/248\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/media?parent=248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/categories?post=248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/tags?post=248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}