SlideShare a Scribd company logo
1 of 13
WELCOME TO 
RUBY! 
with rails
WHAT IS RUBY? 
간결함과 생산성을 강조한 동적인 오픈 소스 
프로그래밍 언어입니다. 
루비의 우아한 문법으로 자연스럽게 읽고 쓰기 
편한 프로그램을 만들수 있습니다.
C++ VS RUBY VS JAVA 
SCRIPT 
▪ C++ 
for(int i = 0; i < 5; ++i) 
puts(“hello”); 
▪ RUBY 
5.times { puts “hello” } 
▪ Java Script 
for (var i = 0; i <= 5; i++) 
puts(“hello”);
모든 것은 객체다. 
▪ 처음에 마츠는 이상적인 문법을 가진 언어를 찾고 있 
었다. 그 때를 회고하며 그는 “나는 펄보다 강력하고 파 
이썬보다는 객체지향적인 스크립트 언어가 필요했다” 
라고 말해다. 
▪ 루비에서는 모든 것이 객체이다. 따라서 루비에서 모 
든 것은 자신만의 속성과 액션을 갖는다. 객체지향 프 
로그래밍에서 이런 속성을 인스턴스 변수라고 하고, 
액션을 메서드라고 한다.
루비의 유연함 
▪ 개발자가 루비의 어떤 부분이든 자유롭게 바꿀 수 있기 때문에 매 
우 유연한 언어라고 할 수 있다. 원한다면 루비 코어 부분도 제거하 
고 재정의할 수 있다. 이미 존재하는 코드에 무엇인가를 덧붙일 수 
도 있다. 루비는 기본적으로 개발자의 사고를 제한하지 않는다. 
class Numeric 
def plus(x) 
self.+(x) 
end 
end 
y = 5.plus 6 
# 이제 y는 11이 되었다
블럭 
▪블록은 코드를 데이터와 같이 취급하게 해주는 기능이다. 즉, 
함수를 정의하는 식으로 블록을 정의하여 다른 메소드에 이를 
인자로 넘길 수 있다. 
>> ["apple", "banana", "orange"].map {|fruit| fruit.upcase} 
=> ["APPLE", "BANANA", "ORANGE"]
텍스트 처리 #01 
▪루비의 텍스트 처리 기능은 Perl을 그대로 벤치마킹했다. 
▪여기서 주목할 부분은 루비가 Perl 스타일의 텍스트 처리 
기능을 온전히 객체지향적으로 구현하고 있다는 점이다 
>> /([0-9]+)/.class 
=> Regexp 
>> /([0-9]+)/.=~("A year has 365 days.") 
=> 11 
# 0-9 즉 숫자가 있는 첫 위치를 반환
텍스트 처리 #02 
▪텍스트 처리에 있어 정규식의 주요 사용 케이스 중 하나는 
바로 텍스트의 일부를 치환하는 작업이다. 
▪루비에서는 문자열 객체의 'sub' 메소드와 정규식 패턴을 
사용하여 문자열의 특정 부분을 치환할 수 있다. 
>> "banana".sub(/a/, "@") 
=> "b@nana"
텍스트 처리 #03 
▪매칭되는 모든 패턴을 치환하고 싶다면, 'sub' 대신에 'gsub'를 
사용한다. 
>> "banana".gsub(/a/, "@") 
=> "b@n@n@"
프로시저 (proc) 
▪ Proc와 블럭의 다른 점이라면, 블럭은 한번만 사용하기 위해서 적당한 방법이고 
Proc는 재 사용이 가능하다라는 점이다. 
class MyClass 
def initilize(thing, &action) 
@action = action 
end 
def do_thing 
@action.call(self) 
end 
end 
run = MyClass.new("RUN") { ... } 
stop = MyClass.new("STOP") { ... }
람다 (lambda) 
▪익명함수다. 프로시저처럼 재사용이 가능하다. 차이라고 하면 리턴 값을 사용할 수 있다. 
말그대로 익명 함수 이므로. 
def n_times(thing) 
return lambda {|n| thing * n } 
end 
p1 = n_times(23) 
p1.call(3) -> 69 
p1.call(4) -> 92 
p2 = n_times("Hello ") 
p2.call(3) -> "Hello Hello Hello "
TRY! RUBY! 
▪http://tryruby.org/
참고 자료 
▪http://tryruby.org/ 
▪http://ruby-lang.org/ko 
▪http://beyond.daesan.com/pages/ruby-broadens-your- 
thinking 
▪인사이트 프로그래밍 
루비 http://www.yes24.com/24/goods/2314079

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Welcome to ruby!

  • 1. WELCOME TO RUBY! with rails
  • 2. WHAT IS RUBY? 간결함과 생산성을 강조한 동적인 오픈 소스 프로그래밍 언어입니다. 루비의 우아한 문법으로 자연스럽게 읽고 쓰기 편한 프로그램을 만들수 있습니다.
  • 3. C++ VS RUBY VS JAVA SCRIPT ▪ C++ for(int i = 0; i < 5; ++i) puts(“hello”); ▪ RUBY 5.times { puts “hello” } ▪ Java Script for (var i = 0; i <= 5; i++) puts(“hello”);
  • 4. 모든 것은 객체다. ▪ 처음에 마츠는 이상적인 문법을 가진 언어를 찾고 있 었다. 그 때를 회고하며 그는 “나는 펄보다 강력하고 파 이썬보다는 객체지향적인 스크립트 언어가 필요했다” 라고 말해다. ▪ 루비에서는 모든 것이 객체이다. 따라서 루비에서 모 든 것은 자신만의 속성과 액션을 갖는다. 객체지향 프 로그래밍에서 이런 속성을 인스턴스 변수라고 하고, 액션을 메서드라고 한다.
  • 5. 루비의 유연함 ▪ 개발자가 루비의 어떤 부분이든 자유롭게 바꿀 수 있기 때문에 매 우 유연한 언어라고 할 수 있다. 원한다면 루비 코어 부분도 제거하 고 재정의할 수 있다. 이미 존재하는 코드에 무엇인가를 덧붙일 수 도 있다. 루비는 기본적으로 개발자의 사고를 제한하지 않는다. class Numeric def plus(x) self.+(x) end end y = 5.plus 6 # 이제 y는 11이 되었다
  • 6. 블럭 ▪블록은 코드를 데이터와 같이 취급하게 해주는 기능이다. 즉, 함수를 정의하는 식으로 블록을 정의하여 다른 메소드에 이를 인자로 넘길 수 있다. >> ["apple", "banana", "orange"].map {|fruit| fruit.upcase} => ["APPLE", "BANANA", "ORANGE"]
  • 7. 텍스트 처리 #01 ▪루비의 텍스트 처리 기능은 Perl을 그대로 벤치마킹했다. ▪여기서 주목할 부분은 루비가 Perl 스타일의 텍스트 처리 기능을 온전히 객체지향적으로 구현하고 있다는 점이다 >> /([0-9]+)/.class => Regexp >> /([0-9]+)/.=~("A year has 365 days.") => 11 # 0-9 즉 숫자가 있는 첫 위치를 반환
  • 8. 텍스트 처리 #02 ▪텍스트 처리에 있어 정규식의 주요 사용 케이스 중 하나는 바로 텍스트의 일부를 치환하는 작업이다. ▪루비에서는 문자열 객체의 'sub' 메소드와 정규식 패턴을 사용하여 문자열의 특정 부분을 치환할 수 있다. >> "banana".sub(/a/, "@") => "b@nana"
  • 9. 텍스트 처리 #03 ▪매칭되는 모든 패턴을 치환하고 싶다면, 'sub' 대신에 'gsub'를 사용한다. >> "banana".gsub(/a/, "@") => "b@n@n@"
  • 10. 프로시저 (proc) ▪ Proc와 블럭의 다른 점이라면, 블럭은 한번만 사용하기 위해서 적당한 방법이고 Proc는 재 사용이 가능하다라는 점이다. class MyClass def initilize(thing, &action) @action = action end def do_thing @action.call(self) end end run = MyClass.new("RUN") { ... } stop = MyClass.new("STOP") { ... }
  • 11. 람다 (lambda) ▪익명함수다. 프로시저처럼 재사용이 가능하다. 차이라고 하면 리턴 값을 사용할 수 있다. 말그대로 익명 함수 이므로. def n_times(thing) return lambda {|n| thing * n } end p1 = n_times(23) p1.call(3) -> 69 p1.call(4) -> 92 p2 = n_times("Hello ") p2.call(3) -> "Hello Hello Hello "
  • 13. 참고 자료 ▪http://tryruby.org/ ▪http://ruby-lang.org/ko ▪http://beyond.daesan.com/pages/ruby-broadens-your- thinking ▪인사이트 프로그래밍 루비 http://www.yes24.com/24/goods/2314079