SlideShare a Scribd company logo
Ruby ile tanışma!
Uğur "vigo" Özyılmazel
vigobronx vigo
webboxio
http://webbox.io
PROGRAMLAMA DİLİ
Ruby ile tanışma!
Ruby, programcıları
mutlu etmek üzere
tasarlanmıştır!
- Matz
Ruby ile tanışma!
TÜRKÇE BİLİYOR!
şehirler = %w[İstanbul Ankara Viyana Paris]
gittiğim_şehirler = %w[İstanbul Viyana]
puts "Gitmem gereken şehirler", şehirler - gittiğim_şehirler
Gitmem gereken şehirler
Ankara
Paris
Perl'den güçlü
python'dan daha
object orıented
Herşey : nesne
5.class # => Fixnum
5.class.superclass # => Integer
5.class.superclass.superclass # => Numeric
5.class.superclass.superclass.superclass # => Object
5.class.superclass.superclass.superclass.superclass # => BasicObject
Fixnum
Integer
Numeric
Object
Basic Object
5.methods # => [:to_s, :inspect, :-@, :+, :-, :*, :/, :div, :
%, :modulo, :divmod, :fdiv, :**, :abs, :magnitude, :==, :===, :<=>, :
>, :>=, :<, :<=, :~, :&, :|, :^, :
[], :<<, :>>, :to_f, :size, :bit_length, :zero?, :odd?, :even?, :succ
, :integer?, :upto, :downto, :times, :next, :pred, :chr, :ord, :to_i,
:to_int, :floor, :ceil, :truncate, :round, :gcd, :lcm, :gcdlcm, :nume
rator, :denominator, :to_r, :rationalize, :singleton_method_added, :c
oerce, :i, :
+@, :eql?, :remainder, :real?, :nonzero?, :step, :quo, :to_c, :real,
:imaginary, :imag, :abs2, :arg, :angle, :phase, :rectangular, :rect,
:polar, :conjugate, :conj, :between?, :nil?, :=~, :!~, :hash, :class,
:singleton_class, :clone, :dup, :taint, :tainted?, :untaint, :untrust
, :untrusted?, :trust, :freeze, :frozen?, :methods, :singleton_method
s, :protected_methods, :private_methods, :public_methods, :instance_v
ariables, :instance_variable_get, :instance_variable_set, :instance_v
ariable_defined?, :remove_instance_variable, :instance_of?, :kind_of?
, :is_a?, :tap, :send, :public_send, :respond_to?, :extend, :display,
:method, :public_method, :singleton_method, :define_singleton_method,
:object_id, :to_enum, :enum_for, :equal?, :!, :!
=, :instance_eval, :instance_exec, :__send__, :__id__]
TÜM SINIFLAR AÇIKTIR!
class Fixnum
def kere(n)
self * n
end
end
5.kere(5) # => 25
5.kere(5).kere(2) # => 50
class Fixnum
def gün
self * 24 * 60 * 60
end
def önce
Time.now - self
end
def sonra
Time.now + self
end
end
Time.now # => 2015-01-12 12:30:37 +0200
5.gün.önce # => 2015-01-07 12:30:37 +0200
1.gün.sonra # => 2015-01-13 12:30:37 +0200
PHP?
konuşma dİlİne benzer
5.times do |i|
puts "Ruby’i seviyorum, i = #{i}" if i > 2
end
# Ruby’i seviyorum, i = 3
# Ruby’i seviyorum, i = 4
meals = %w[Pizza Döner Kebab]
print "Let’s eat here!" unless meals.include? "Soup"
menü'de çorba yoksa
yemeğİ burada YİYELİM!
KOD ?
varıable
merhaba = "Dünya" # Değişken
@merhaba # Instance Variable
@@merhaba # Class Variable
$merhaba # Global Variable
MERHABA # Constant
ARRAY
[] # => []
[1, "Merhaba", 2]
# => [1, "Merhaba", 2]
[[1, 2], ["Merhaba", "Dünya"]]
# => [[1, 2], ["Merhaba", "Dünya"]]
hash
{} # => {}
{:foo => "bar"} # => {:foo=>"bar"} # Eski
{foo: "bar"} # => {:foo=>"bar"} # Yeni
parantez?
def merhaba kullanıcı
"Merhaba #{kullanıcı}"
end
merhaba "vigo" # => "Merhaba vigo"
SORU İŞARETİ
[].empty? # => true
["vigo", "ezel"].include? "vigo" # => true
user.admin? # => false
ÜNLEM İŞARETİ
isim = "vigo"
isim.reverse # => "ogiv"
isim # => "vigo"
isim.reverse! # => "ogiv"
isim # => "ogiv"
zİNCİRLEME METHODLAR
"vigo".reverse.reverse # => "vigo"
["v", "i", "g", "o"].join.reverse.split(//).join.reverse
# => "vigo"
İterasyon
[1, "merhaba", 2, "dünya"].each do |eleman|
puts eleman
end
[1, "merhaba", 2, "dünya"].each {|eleman| puts eleman}
# 1
# merhaba
# 2
# dünya
İterasyon
[1, 2, 3, 4, 5].select{|number| number.even?}
# => [2, 4]
[1, 2, 3, 4, 5].inject{|sum, number| sum + number}
# => 15
[1, 2, 3, 4, 5].map{|number| number * 2}
# => [2, 4, 6, 8, 10]
class
class Person
attr_accessor :age
end
vigo = Person.new
vigo # => #<Person:0x007f98820e6ab0>
vigo.age = 43
vigo # => #<Person:0x007f98820e6ab0 @age=43>
vigo.age # => 43
class
class Person
attr_accessor :age # Getter & Setter
def initialize(name)
@name = name
end
def greet
"Hello #{@name}"
end
end
vigo = Person.new "Uğur"
vigo.age = 43
vigo # => #<Person:0x007fc2810436c0 @name="Uğur", @age=43>
vigo.greet # => "Hello Uğur"
class
class Person
def initialize(name)
@name = name
end
def age=(value)
@age = value
end
def age
@age
end
def greet
"Hello #{@name}"
end
end
vigo = Person.new "Uğur"
vigo.age = 43
Getter
Setter
attr_accessor :age
}
class
class Person
def is_human?
true
end
end
class Cyborg < Person
def is_human?
false
end
end
vigo = Person.new # => #<Person:0x007faa7291d268>
vigo.is_human? # => true
t800 = Cyborg.new # => #<Cyborg:0x007faa7291cbd8>
t800.is_human? # => false
module + MIXIN
module Greeter
def say_hello
"Hello #{@name}"
end
end
class Person
include Greeter
def initialize(name)
@name = name
end
end
vigo = Person.new "Uğur"
vigo.say_hello # => "Hello Uğur"
hazırım!
İLERİ SEVİYE KONULAR
Meta Programming
Monkey Patching
Block & Proc & Lambda
Functional Programming
kaynaklar
http://www.ruby-doc.org/
http://vigo.gitbooks.io/ruby-101/
http://tryruby.org/
http://rubykoans.com/
https://rubymonk.com/
https://www.ruby-lang.org/en/documentation/quickstart/
https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/
fotoğraflar
http://www.sitepoint.com/
https://500px.com/photo/72621187/let-me-fly-by-kshitij-bhardwaj
http://www.gratisography.com/

More Related Content

KEY
FizzBuzzではじめるテスト
KEY
Pecha Kucha
PDF
De 0 a 100 con Bash Shell Scripting y AWK
PDF
ภาษา C
PPTX
Joy of Six - Discover the Joy of Perl 6
PDF
My First Ruby
ZIP
PDF
Efficient JavaScript Development
FizzBuzzではじめるテスト
Pecha Kucha
De 0 a 100 con Bash Shell Scripting y AWK
ภาษา C
Joy of Six - Discover the Joy of Perl 6
My First Ruby
Efficient JavaScript Development

What's hot (20)

PDF
CGI.pm - 3ло?!
PDF
Coffeescript - Getting Started
KEY
Tripwon gathering presentation
TXT
Getfilestruct zbksh(1)
PDF
Islam House
PDF
Mojolicious: what works and what doesn't
PPTX
London XQuery Meetup: Querying the World (Web Scraping)
PDF
Nomethoderror talk
PDF
JavaScript - Like a Box of Chocolates - jsDay
KEY
Rails by example
PPTX
SQL Injection Part 2
PDF
TDDBC お題
PDF
Import o matic_higher_ed
PDF
KEY
PHPerのためのPerl入門@ Kansai.pm#12
PDF
Blog Hacks 2011
PDF
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
PDF
Python Developer's Daily Routine
PDF
Michelle Morin: Recess for the Soul
PDF
Barcelona.pm Curs1211 sess01
CGI.pm - 3ло?!
Coffeescript - Getting Started
Tripwon gathering presentation
Getfilestruct zbksh(1)
Islam House
Mojolicious: what works and what doesn't
London XQuery Meetup: Querying the World (Web Scraping)
Nomethoderror talk
JavaScript - Like a Box of Chocolates - jsDay
Rails by example
SQL Injection Part 2
TDDBC お題
Import o matic_higher_ed
PHPerのためのPerl入門@ Kansai.pm#12
Blog Hacks 2011
レッツゴーデベロッパー2011「プログラミングGroovy〜G*エコシステム編」
Python Developer's Daily Routine
Michelle Morin: Recess for the Soul
Barcelona.pm Curs1211 sess01
Ad

Similar to Ruby ile tanışma! (20)

KEY
An introduction to Ruby
PDF
[PL] Jak nie zostać "programistą" PHP?
PDF
Blocks by Lachs Cox
PDF
Ruby 入門 第一次就上手
KEY
Refactor like a boss
PDF
Ruby 2.0
PDF
Ruby - Uma Introdução
PPTX
Word Play in the Digital Age: Building Text Bots with Tracery
PDF
Úvod do programování 5
KEY
RubyMotion
PPTX
PHP Basics and Demo HackU
PPT
2007 09 10 Fzi Training Groovy Grails V Ws
PDF
Swift Basics
PPTX
Getting Started with Microsoft Bot Framework
PPT
PHP and MySQL
PDF
Ruby 程式語言綜覽簡介
KEY
ODP
Nigel hamilton-megameet-2013
PPT
Joomla! Day UK 2009 .htaccess
An introduction to Ruby
[PL] Jak nie zostać "programistą" PHP?
Blocks by Lachs Cox
Ruby 入門 第一次就上手
Refactor like a boss
Ruby 2.0
Ruby - Uma Introdução
Word Play in the Digital Age: Building Text Bots with Tracery
Úvod do programování 5
RubyMotion
PHP Basics and Demo HackU
2007 09 10 Fzi Training Groovy Grails V Ws
Swift Basics
Getting Started with Microsoft Bot Framework
PHP and MySQL
Ruby 程式語言綜覽簡介
Nigel hamilton-megameet-2013
Joomla! Day UK 2009 .htaccess
Ad

More from Uğur Özyılmazel (7)

PDF
Test'le Yürüyen Geliştirme (TDD)
PDF
Vagrant 101
PDF
Yazilimci kimdir?
PDF
Nginx ve Unicorn'la Rack Uygulamalarını Koşturmak
PDF
İnsanlar için GIT
PDF
Merhaba Sinatra
PDF
Python ve Django'da Test'le Yürüyen Geliştirme
Test'le Yürüyen Geliştirme (TDD)
Vagrant 101
Yazilimci kimdir?
Nginx ve Unicorn'la Rack Uygulamalarını Koşturmak
İnsanlar için GIT
Merhaba Sinatra
Python ve Django'da Test'le Yürüyen Geliştirme

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
System and Network Administration Chapter 2
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
top salesforce developer skills in 2025.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Designing Intelligence for the Shop Floor.pdf
Design an Analysis of Algorithms I-SECS-1021-03
System and Network Administration Chapter 2
Computer Software and OS of computer science of grade 11.pptx
CHAPTER 2 - PM Management and IT Context
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
Nekopoi APK 2025 free lastest update
Digital Systems & Binary Numbers (comprehensive )
Wondershare Filmora 15 Crack With Activation Key [2025
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
wealthsignaloriginal-com-DS-text-... (1).pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
top salesforce developer skills in 2025.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Operating system designcfffgfgggggggvggggggggg
How to Choose the Right IT Partner for Your Business in Malaysia

Ruby ile tanışma!