Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Ruby 101
Uğur Özyılmazel
November 24, 2018
Programming
1
73
Ruby 101
Basic ruby introduction for Railsgirls İstanbul 2018
Uğur Özyılmazel
November 24, 2018
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
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
Ruby'i Tanıyalım
vigo
0
230
Other Decks in Programming
See All in Programming
Licences open source : entre guerre de clochers et radicalité
pylapp
2
350
不具合に立ち向かう テスト戦略 ~ NestJSで作るCI環境 ~
naoki_haba
0
110
近況PHP / PHP in now a days
uzulla
4
1.9k
Milestoner
bkuhlmann
1
200
あなたの会社の古いシステム、なんとかしませんか?~システム刷新から考えるDX化への道筋とバリエーション~/webinar20220420-grapecity
grapecity_dev
0
140
[RailsConf 2022] The pitfalls of realtime-ification
palkan
0
290
Update from the Elixir team - 2022
whatyouhide
0
200
スモールチームがAmazon Cognitoでコスパよく作るサービス間連携認証
tacke_jp
2
830
httputil.ReverseProxy でもリトライがしたい
toga4
0
120
GraphQL+KMM開発でわかったこと / What we learned from GraphQL+KMM development
kubode
0
130
Groovy Roadmap
paulk
7
13k
LOWYAの信頼性向上とNew Relic
kazumax55
4
370
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
295
110k
Building Adaptive Systems
keathley
25
1.1k
How to train your dragon (web standard)
notwaldorf
57
3.8k
Reflections from 52 weeks, 52 projects
jeffersonlam
337
17k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_i
21
14k
Why Our Code Smells
bkeepers
PRO
324
54k
YesSQL, Process and Tooling at Scale
rocio
157
12k
Build your cross-platform service in a week with App Engine
jlugia
219
17k
VelocityConf: Rendering Performance Case Studies
addyosmani
316
22k
5 minutes of I Can Smell Your CMS
philhawksworth
196
18k
How STYLIGHT went responsive
nonsquared
85
3.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
349
27k
Transcript
None
Uğur "vigo" Özyılmazel vigobronx vigo
PROGRAMLAMA DİLİ
None
Ruby, programcıları mutlu etmek üzere tasarlanmıştır! - Matz
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
Herşey : nesne
5.class # => Integer 5.class.superclass # => Numeric 5.class.superclass.superclass #
=> Object 5.class.superclass.superclass.superclass # => BasicObject 5.class.superclass.superclass.superclass.superclass # => nil
Integer Numeric Object Basic Object
5.methods # => [:- @, :**, :<=>, :upto, :<<, :<=,
:>=, :==, :chr, :===, :>>, :[], : %, :&, :inspect, : +, :ord, :-, :/, :*, :size, :succ, :<, :>, :to_int, :coerce, :divmod, :to_ s, :to_i, :fdiv, :modulo, :remainder, :abs, :magnitude, :lcm, :integer?, : rationalize, :gcdlcm, :gcd, :denominator, :floor, :ceil, :round, :truncate , :to_r, :to_f, :^, :odd?, :even?, :allbits?, :anybits?, :nobits?, :downto , :times, :pred, :pow, :bit_length, :digits, :numerator, :next, :div, :|, :~, : +@, :conjugate, :eql?, :singleton_method_added, :i, :real?, :zero?, :nonze ro?, :finite?, :infinite?, :step, :positive?, :negative?, :angle, :real, : to_c, :conj, :phase, :imag, :abs2, :arg, :imaginary, :rectangular, :rect, :clone, :dup, :polar, :quo, :between?, :clamp, :instance_variable_set, :in stance_variable_defined?, :remove_instance_variable, :instance_of?, :kind_ of?, :is_a?, :tap, :instance_variable_get, :public_methods, :instance_vari ables, :method, :public_method, :define_singleton_method, :singleton_metho d, :public_send, :extend, :pp, :to_enum, :enum_for, :=~, :! ~, :respond_to?, :freeze, :object_id, :send, :display, :nil?, :hash, :clas s, :singleton_class, :yield_self, :itself, :tainted?, :taint, :untrust, :u ntaint, :trust, :untrusted?, :methods, :frozen?, :singleton_methods, :prot ected_methods, :private_methods, :!, :equal?, :instance_eval, :instance_ex ec, :!=, :__id__, :__send__]
TÜM SINIFLAR AÇIKTIR!
class Integer def kere(n) self * n end end 5.kere(5)
# => 25 5.kere(5).kere(2) # => 50
class Integer def gün self * 24 * 60 *
60 end def önce Time.now - self end def sonra Time.now + self end end Time.now # => 2018-11-23 14:42:23 +0300 5.gün.önce # => 2018-11-18 14:42:23 +0300 1.gün.sonra # => 2018-11-24 14:42:23 +0300
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!
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:0x00007fef1693fe60> vigo.age = 46 vigo # => #<Person:0x00007fef1693fe60 @age=46> vigo.age # => 46
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 = 46 vigo # => #<Person:0x00007f889b056c40 @name="Uğur", @age=46> 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"
İ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/