Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Ruby'i Tanıyalım
Uğur Özyılmazel
January 17, 2015
Programming
0
230
Ruby'i Tanıyalım
17 OCAK RUBY VE RUBY ON RAİLS İLE TANIŞMA ETKİNLİĞİ için yapmış olduğum Ruby tanıtım sunumu.
Uğur Özyılmazel
January 17, 2015
Tweet
Share
More Decks by Uğur Özyılmazel
See All by Uğur Özyılmazel
Makefile değil, Rakefile
vigo
1
400
Bir Django Projesi : <Buraya RUBY ekleyin>
vigo
1
280
Ruby 101
vigo
1
73
Django
vigo
4
350
Gündelik Hayatta GIT İpuçları
vigo
3
520
Bash 101
vigo
3
430
TDD - Test Driven Development
vigo
2
120
Vagrant 101
vigo
2
170
Yazılımcı Kimdir?
vigo
0
320
Other Decks in Programming
See All in Programming
クックパッドマートの失敗したデータ設計 Before / After 大放出
mokuzon
0
180
模組化的Swift架構(二) DDD速成
haifengkao
0
390
A Philosophy of Software Design 後半
yosuke_furukawa
PRO
10
2.9k
Baseline Profilesでアプリのパフォーマンスを向上させる / Improve app performance with Baseline Profiles
numeroanddev
0
260
Why Airflow? & What's new in Airflow 2.3?
kaxil
0
120
Beyond Micro Frontends: Frontend Moduliths for the Enterprise @enterjs2022
manfredsteyer
PRO
0
200
Beyond Micro Frontends: Frontend Moduliths for the Enterprise @wad2022
manfredsteyer
PRO
0
140
こそこそアジャイル導入しようぜ!
ichimichi
0
1.3k
チームでカレーを作ろう!アジャイルカレークッキング
akitotsukahara
0
890
短納期でローンチした新サービスをJavaで開発した話/launched new service using Java
eichisanden
6
2k
大規模プロダクトにLinterを導入し運用している話
hirokiotsuka
0
240
The strategies behind ddd – AdeoDevSummit 2022
lilobase
PRO
5
270
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
28
6.6k
What the flash - Photography Introduction
edds
62
10k
The Art of Programming - Codeland 2020
erikaheidi
32
11k
The Brand Is Dead. Long Live the Brand.
mthomps
46
2.7k
Product Roadmaps are Hard
iamctodd
34
6.6k
Intergalactic Javascript Robots from Outer Space
tanoku
261
25k
Large-scale JavaScript Application Architecture
addyosmani
499
110k
No one is an island. Learnings from fostering a developers community.
thoeni
9
1.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
5
510
We Have a Design System, Now What?
morganepeng
35
3k
Mobile First: as difficult as doing things right
swwweet
213
7.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
Transcript
None
Uğur "vigo" Özyılmazel vigobronx vigo
webboxio http://webbox.io
PROGRAMLAMA DİLİ
None
Ruby, programcıları mutlu etmek üzere tasarlanmıştır! - Matz
None
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/