29
RUBY + RAILS A really tiny introduction. FEU - East Asia College — 11 February 2014

Ruby on Rails Introduction | FEU-EAC, February 2014

Embed Size (px)

Citation preview

Page 1: Ruby on Rails Introduction | FEU-EAC, February 2014

RUBY + RAILSA really tiny introduction.

FEU - East Asia College — 11 February 2014

Page 2: Ruby on Rails Introduction | FEU-EAC, February 2014

こ ん に ち は ル ビ ー

Page 3: Ruby on Rails Introduction | FEU-EAC, February 2014
Page 4: Ruby on Rails Introduction | FEU-EAC, February 2014

LEARN

Page 5: Ruby on Rails Introduction | FEU-EAC, February 2014

LEARNby example :)

Page 6: Ruby on Rails Introduction | FEU-EAC, February 2014

ハローワールド

public class Hello {! public static void main(String[] args) {! System.out.println(“Ohayou, Ruby!”);! }!}

Hello.java

Page 7: Ruby on Rails Introduction | FEU-EAC, February 2014

ハローワールド

public class Hello {! public static void main(String[] args) {! System.out.println(“Ohayou, Ruby!”);! }!}

puts “Ohayou Ruby!”

Hello.java

hello.rb

Page 8: Ruby on Rails Introduction | FEU-EAC, February 2014
Page 9: Ruby on Rails Introduction | FEU-EAC, February 2014

ハローワールド

public class Hello {! public static void main(String[] args) {! System.out.println(“Ohayou, Ruby!”);! }!}

puts “Ohayou Ruby!”

Hello.java

hello.rb

110

Page 10: Ruby on Rails Introduction | FEU-EAC, February 2014

ハローワールド

public class Hello {! public static void main(String[] args) {! System.out.println(“Ohayou, Ruby!”);! }!}

puts “Ohayou Ruby!”

Hello.java

hello.rb

110

19

Page 11: Ruby on Rails Introduction | FEU-EAC, February 2014

578 %Productivity Gain

Page 12: Ruby on Rails Introduction | FEU-EAC, February 2014

578 %Productivity Gain

(I don’t really know what I’m doing.)

Page 13: Ruby on Rails Introduction | FEU-EAC, February 2014
Page 14: Ruby on Rails Introduction | FEU-EAC, February 2014

反復するpublic class Loop {! public static void main(String[] args) {!! ! String fruits[] = new String[]{“apple”, “orange”}! for(int i = 0; i < fruits.length; i++){!! ! ! System.out.println(fruit[i]);!! ! }! }!}

Loop.java

Page 15: Ruby on Rails Introduction | FEU-EAC, February 2014

反復するpublic class Loop {! public static void main(String[] args) {!! ! String fruits[] = new String[]{“apple”, “orange”}! for(int i = 0; i < fruits.length; i++){!! ! ! System.out.println(fruit[i]);!! ! }! }!}

fruits = [“apple”, “orange”]!fruits.each do |fruit| !! puts fruit !end

Loop.java

loop.rb

Page 16: Ruby on Rails Introduction | FEU-EAC, February 2014

反復するpublic class Loop {! public static void main(String[] args) {!! ! String fruits[] = new String[]{“apple”, “orange”}! for(int i = 0; i < fruits.length; i++){!! ! ! System.out.println(fruit[i]);!! ! }! }!}

[“apple”, “orange”].each do |fruit| !! puts fruit !end

Loop.java

loop.rb

Page 17: Ruby on Rails Introduction | FEU-EAC, February 2014

反復するpublic class Loop {! public static void main(String[] args) {!! ! String fruits[] = new String[]{“apple”, “orange”}! for(int i = 0; i < fruits.length; i++){!! ! ! System.out.println(fruit[i]);!! ! }! }!}

[“apple”, “orange”].each { |fruit| puts fruit }

Loop.java

loop.rb

Page 18: Ruby on Rails Introduction | FEU-EAC, February 2014

条件付きの

if(age < 18)!! puts “Minor!”;!elsif(age >= 60)!! puts “Senior”;!elsif(age >= 18 && age < 60)!! puts “Legal Age”;

can_i_go_to_the_club.rb

Page 19: Ruby on Rails Introduction | FEU-EAC, February 2014

条件付きの

if(age < 18)!! puts “Minor!”!elsif(age >= 60)!! puts “Senior”!elsif(age >= 18 && age < 60)!! puts “Legal Age”

can_i_go_to_the_club.rb

Page 20: Ruby on Rails Introduction | FEU-EAC, February 2014

条件付きの

if age < 18!! puts “Minor!”!elsif age >= 60!! puts “Senior”!elsif age >= 18 && age < 60!! puts “Legal Age”

can_i_go_to_the_club.rb

Page 21: Ruby on Rails Introduction | FEU-EAC, February 2014

条件付きの

if age < 18!! puts “Minor!”!elsif age >= 60!! puts “Senior”!elsif age >= 18 and age < 60!! puts “Legal Age”

can_i_go_to_the_club.rb

Page 22: Ruby on Rails Introduction | FEU-EAC, February 2014

コレクション

passed = [] !!students.each do |student|!! if score > 70!! ! passed << student!! end!end

you_shall_not_pass.rb

Page 23: Ruby on Rails Introduction | FEU-EAC, February 2014

コレクション

passed = students.map { |s| s.score > 70 }!passed = students.collect { |s| s.score > 70 }!!— OR — !!passed = students.delete_if { |s| s.score <= 70 }!passed = students.reject { |s| s.score <= 70 }

you_shall_not_pass.rb

Page 24: Ruby on Rails Introduction | FEU-EAC, February 2014

RUBY ON RAILS

Page 25: Ruby on Rails Introduction | FEU-EAC, February 2014
Page 26: Ruby on Rails Introduction | FEU-EAC, February 2014

DEMO TIEM!

Page 27: Ruby on Rails Introduction | FEU-EAC, February 2014

RESOURCES

• https://www.ruby-lang.org/en/

• http://guides.rubyonrails.org/

• http://railscasts.com/

• http://ruby.railstutorial.org/ruby-on-rails-tutorial-book

• http://ruby.learncodethehardway.org/

Page 28: Ruby on Rails Introduction | FEU-EAC, February 2014

SLIDEShttp://slidesha.re/1cq6fkn

Page 29: Ruby on Rails Introduction | FEU-EAC, February 2014

THANK YOU!Ken-Lauren Daganio

@kendaganio