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
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Nekopoi APK 2025 free lastest update
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
history of c programming in notes for students .pptx
PDF
System and Network Administration Chapter 2
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
assetexplorer- product-overview - presentation
PDF
top salesforce developer skills in 2025.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Nekopoi APK 2025 free lastest update
Operating system designcfffgfgggggggvggggggggg
CHAPTER 2 - PM Management and IT Context
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
history of c programming in notes for students .pptx
System and Network Administration Chapter 2
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Softaken Excel to vCard Converter Software.pdf
Understanding Forklifts - TECH EHS Solution
L1 - Introduction to python Backend.pptx
Why Generative AI is the Future of Content, Code & Creativity?
assetexplorer- product-overview - presentation
top salesforce developer skills in 2025.pdf
Computer Software and OS of computer science of grade 11.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Navsoft: AI-Powered Business Solutions & Custom Software Development

Ruby ile tanışma!