meet ruby

Post on 15-Jan-2015

27 Views

Category:

Software

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

little interdiction about ruby & rails

TRANSCRIPT

MEET RUBY

AGENDA

• Introduction

• Code basic

• A sample DEMO in RoR

• RUBY ON RAILS COMMUNITY

INTRODUCTION

THE CREATOR.

THE CREATOR SAY

Hello ruby world

THE CREATOR SAY

THE CREATOR SAY

CODE BASIC

CODE EXAMPLE

5.times { print "hello world!"}# hello world!hello world!hello world!hello world!hello world!

if "text".include? "ex" puts "match"end#matchputs "no match" unless "text".include? "ttt"#no match

CODE EXAMPLE

# this is a coment# a = b -ca = b + c # comment at the end

=begin def my_method .. end=end

CODE EXAMPLE

#Variable Declaration:

a_string = "hello!"a_float = 3.5a_int = 3

#Funcation Declaration:

def do_something(a_string , a_int) puts a_string * 3 puts a_int * 3end tw-hollychung1:myarch masato$ ruby test.rb

hello!hello!hello!9

Language Basics: Strings

Language Basics: Strings

Language Basics: Hashes

Language Basics: Arrays

Give me some sugar: Array

Control Structures

Control Structures2

File.open(“a.txt”,”r”).each_line{|l| puts l}

nums = [1,7,6,3,4]

nums.sort{|a,b| a <=> b}

hashs = { "Jane Doe" => 10, "Jim Doe" => 6 , “Masato” => 9}

hashs.map{|k,v| p v}

PRATTEN MATCH

name , id , company =["Masato","999","RUBYLIST"]

p name => "Masato"

p id => "999"

p company => "RUBYLIST"

Language Basics: Classes

Language Basics: Classes• Classes are always open (even built in classes)

Language Basics: Inheritance• Single Inheritance

▫ But mixins are available (= Interface with implemented methods)

Language Basics: Mixin Example

The ruby world

Libraries - Rubygems

require ‘lib/my_module.rb’

gem searchgem installgem updategem push

RUBY ON RAILS COMMUNITY

RAILS EVENT IN TAIPIE

Q&A?

THANK YOU!

top related