SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
Intoduction to
  RubyCocoa
  (CocoaHead:Thinkboy)




  source: http://www.rubycocoa.com/
Aganda
• Problem?
• What?
• Why?
• How?
• Where?
• Demo?
Neither true or false,
just a matter of choice!
Problem?

• I love Mac OSX GUI (Aqua)
• I love Cocoa
• I love Xcode & Interface Builder
• But programming in Objective-C may be a
  bit of ‘curve’ to get started
From Objective-C
@interface Controller : NSObject
{
     IBOutlet NSWindow *itsWindow;
}
- (IBAction)changeTransparency:(id)sender;
@end
@implementation Controller
- (IBAction)changeTransparency:(id)sender
{	
     [itsWindow setAlphaValue:[sender floatValue]];
     [itsWindow display];
}
@end
To RubyCocoa
class Controller < OSX::NSObject
    ib_outlet :itsWindow
    def changeTransparency(sender)
        @itsWindow.setAlphaValue(sender.floatValue)
        @itsWindow.display
    end
end
Differences?
• ruby vs many other programming lang
• ruby vs objective-c vs java
• more comparison
• benchmark comparison
 Again, it is just a matter of choice
    and, perhaps, depending on
             requirement.
What is Ruby?
• Created by Yukihiro "Matz" Matsumoto in 1993
• PURE object-oriented             “if it walks like a duck,
                                   and talks like a duck,
                                   then it might as well be a duck.”



• Dynamic typing (duck typing)
                                   ~ Dave Thomas




• Interpreted language (scripting language)
• Designed for programmer productivity and fun
• Follow the principle of least surprise (POLS)
    in short, when u look at the
    syntax, u feel like home.
    that’s all.
Ruby Learning Trail

• quick tutorial
• interactive practice
• Programming Ruby by Dave Thomas
• Ruby Pocket Reference (O'Reilly 2007)
• more recommendation
When to use
        RubyCocoa?
Ruby           Ruby
                          Domain Specific
                           Application
JRuby       RubyCocoa      Runtime Bridge

Java        Objective-C   Core/ Framework

 C              C          System/Native
What is RubyCocoa?
• created by Hisakuni Fujimoto in 2001
• a bridge that makes it possible for Ruby
  scripts to access Objective-C objects
• like SWIG? but better!       Ruby and Objective C
                               share a common
                               ancestor in Smalltalk
                                                       tool like SWIG which
                                                       reads C and C++ source
                                                       files and automatically


• automatically create
                                                       writes the glue code that
                       Ruby proxy objects              wraps C functions for
                                                       other languages.
                                                       Objective-C uses for
  that are bridged to Objective-C classes.             dynamic message




• forwards Ruby messages to the instances of
  Objective-C classes.                                  by automatically
                                                        creating Ruby proxy
                                                        objects that are bridged


• so what? mixing Ruby and Objective-C in
                                                        to Objective-C classes.

                                                        for wards Ruby messages
                                                        to the instances of these

  the same source files.                                 Objective-C classes.
Why RubyCocoa?
• officially supported by Apple
• full support in Xcode3 (e.g. color syntax, auto
  complete, formatting)
• supports all important features of Cocoa, such as
  key-value coding, key-value observing, Core Data,
  the document architecture, notifications, and undo
  management.
• standard package in 10.5: ruby 1.8.6, rubycocoa,
  RubyGems, rake , Rails , Mongrel , Capistrano,
  Ferret, OpenID, sqlite3-ruby, libxml-ruby, dnssd,
  net-ssh and net-sftp
RubyCocoa How-To?
1. install RubyCocoa 0.13.0
2. create Cocoa-Ruby Application in Xcode3
3. add ScriptingBridge.framework
4. create new ruby controller by subclass
   NSObject
5. create label and button
6. connect controller to ib_outlet & ib_action
ITunesController.rb
require 'osx/cocoa'
include OSX

class ITunesController < NSObject
    ib_outlet :text_field
	
    def show_version(sender)
        iTunes =
SBApplication.applicationWithBundleIdentifier:'com.apple.iTunes'
        @text_field.setStringValue("iTunes version:
#{iTunes.version}")
		
    end
    ib_action :show_version
end
Quick Tutorial?
1. This (Shortest) Tutorial:
  http://cocoalocker.blogspot.com/2007/11/
  ruby-cocoa.html


2. Other Tutorial from YouTube
  http://www.youtube.com/watch?v=7q_DD-
  W6-oI&eurl=http://technorati.com/videos/
  youtube.com%2Fwatch%3Fv%3D7q_DD-
  W6-oI
RubyCocoa ri Doc?

• install rubycocoa-0.13.0.tar manually.
• ruby install config
• ruby install doc
• in the folder /RubyCocoa-0.13.0/
  framework/bridge-doc/
Where to Fish?
• Warn! apple official doc is not so accurate!!
 • doc example does not work on Xcode3
• lets learn by example:
 • /Developer/Examples/Ruby/RubyCocoa
 • Must Read: official RubyCocoa site
 • Mailing list: rubycocoa-talk
NXT Demo!
Demo Setup
• RubyCocoa that remote control NXT
• install Lego Mindstorms NXT 1.1 software
• setup bluetooth device from Mac to NXT
• gem install ruby-nxt 0.8.1
• download and compile ruby-serialport 0.6
• create a RubyCocoa apps in Xcode3
 source: www.bluetooth.com
                             +   +
Demo Architecture
    Ruby                       LabVIEW/C / Java


  Ruby-NXT                    NXT-G/RobotC/Lejos

                  Bluetooth
Ruby-SerialPort                 NXT Firmware
NxtController.rb
require 'osx/cocoa'
class NxtController < OSX::NSObject


      ib_outlet :command_mode

      ib_outlet :run_state

      ib_outlet :tacho_count

      ib_action :move_forward

      

      def initialize

      
      @nxt = NXTComm.new($DEV)

      end


       def move_forward

       
    @command_mode.setStringValue("Moving forward...")

       
    command = Commands::Move.new(@nxt)
 

       
    command.ports = :a, :b, :c

       
    command.duration = {:seconds => 1}

       
    command.next_action = :brake

       
    @run_state.setStringValue("Run State: #{command.message1.inspect}")

       
    @tacho_count.setStringValue("Tacho Count: #{command.message2.inspect}")

       

       
    command.duration = :unlimited

       
    command.start

       
    sleep(1)

       
    command.stop

       end
.....

* ported from the tk example of ruby-nxt
More About NXT
• NXT blog
  http://nxtasy.org/
• NXT programming Software
  http://www.teamhassenplug.org/NXT/
  NXTSoftware.html
• Interesting Projects
  http://www.youtube.com/watch?v=I8VvTENzPGI
  http://www.youtube.com/watch?v=0sl1Q6S3yuo
  http://www.youtube.com/watch?v=s0G35-xoRfA
Q &A
Email: manchi.leung@gmail.com

Mais conteúdo relacionado

Mais procurados

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Rubykim.mens
 
JavaScript as Development Platform
JavaScript as Development PlatformJavaScript as Development Platform
JavaScript as Development PlatformAlexei Skachykhin
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage librarymametter
 
LLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationLLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationVivek Pansara
 
Jfokus 2016 - A JVMs Journey into Polyglot Runtimes
Jfokus 2016 - A JVMs Journey into Polyglot RuntimesJfokus 2016 - A JVMs Journey into Polyglot Runtimes
Jfokus 2016 - A JVMs Journey into Polyglot RuntimesCharlie Gracie
 
Jit builder status and directions 2018 03-28
Jit builder status and directions 2018 03-28Jit builder status and directions 2018 03-28
Jit builder status and directions 2018 03-28Mark Stoodley
 
IronRuby for the .NET Developer
IronRuby for the .NET DeveloperIronRuby for the .NET Developer
IronRuby for the .NET DeveloperCory Foy
 
Rubinius - Ruby Implemented with Ruby
Rubinius - Ruby Implemented with RubyRubinius - Ruby Implemented with Ruby
Rubinius - Ruby Implemented with RubyAkanksha Agrawal
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the RubyistWill Green
 
A bridge between php and ruby
A bridge between php and ruby A bridge between php and ruby
A bridge between php and ruby do_aki
 
RJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperabilityRJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperabilityAkio Tajima
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRubyelliando dias
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...Mickael Istria
 
Esoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in RubyEsoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in Rubymametter
 

Mais procurados (20)

Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Ruby Presentation - Beamer
Ruby Presentation - BeamerRuby Presentation - Beamer
Ruby Presentation - Beamer
 
JavaScript as Development Platform
JavaScript as Development PlatformJavaScript as Development Platform
JavaScript as Development Platform
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
 
LLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationLLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time Optimization
 
Jfokus 2016 - A JVMs Journey into Polyglot Runtimes
Jfokus 2016 - A JVMs Journey into Polyglot RuntimesJfokus 2016 - A JVMs Journey into Polyglot Runtimes
Jfokus 2016 - A JVMs Journey into Polyglot Runtimes
 
Jit builder status and directions 2018 03-28
Jit builder status and directions 2018 03-28Jit builder status and directions 2018 03-28
Jit builder status and directions 2018 03-28
 
IronRuby for the .NET Developer
IronRuby for the .NET DeveloperIronRuby for the .NET Developer
IronRuby for the .NET Developer
 
Rubinius - Ruby Implemented with Ruby
Rubinius - Ruby Implemented with RubyRubinius - Ruby Implemented with Ruby
Rubinius - Ruby Implemented with Ruby
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
 
Jaoo irony
Jaoo ironyJaoo irony
Jaoo irony
 
A bridge between php and ruby
A bridge between php and ruby A bridge between php and ruby
A bridge between php and ruby
 
IronRuby And The DLR
IronRuby And The DLRIronRuby And The DLR
IronRuby And The DLR
 
20140925 rails pacific
20140925 rails pacific20140925 rails pacific
20140925 rails pacific
 
Crystal
CrystalCrystal
Crystal
 
RJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperabilityRJB - another choice for Ruby and Java interoperability
RJB - another choice for Ruby and Java interoperability
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
LLVM
LLVMLLVM
LLVM
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
 
Esoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in RubyEsoteric, Obfuscated, Artistic Programming in Ruby
Esoteric, Obfuscated, Artistic Programming in Ruby
 

Destaque (7)

Perl_Tutorial_v1
Perl_Tutorial_v1Perl_Tutorial_v1
Perl_Tutorial_v1
 
parent_teacher_tutorial
parent_teacher_tutorialparent_teacher_tutorial
parent_teacher_tutorial
 
FrontMatter
FrontMatterFrontMatter
FrontMatter
 
fms9_cwp_php_en
fms9_cwp_php_enfms9_cwp_php_en
fms9_cwp_php_en
 
Day4
Day4Day4
Day4
 
Jeni Intro1 Bab05 Mendapatkan Input Dari Keyboard
Jeni Intro1 Bab05 Mendapatkan Input Dari KeyboardJeni Intro1 Bab05 Mendapatkan Input Dari Keyboard
Jeni Intro1 Bab05 Mendapatkan Input Dari Keyboard
 
Tutorial_4_PHP
Tutorial_4_PHPTutorial_4_PHP
Tutorial_4_PHP
 

Semelhante a ruby-cocoa

MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoaThilo Utke
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overviewjonkinney
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby DevelopersRenzo Borgatti
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Railselliando dias
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVMJung Kim
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overviewThomas Asikis
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureQAware GmbH
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLMario-Leander Reimer
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deploymentThilo Utke
 
Programming iOS in Lua - A bridge story
Programming iOS in Lua - A bridge storyProgramming iOS in Lua - A bridge story
Programming iOS in Lua - A bridge storyjljumpertz
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion IntroductionLori Olson
 
An introduction to the ruby ecosystem
An introduction to the ruby ecosystemAn introduction to the ruby ecosystem
An introduction to the ruby ecosystemGeison Goes
 
Ruby'izing iOS development
Ruby'izing iOS developmentRuby'izing iOS development
Ruby'izing iOS developmenttoamitkumar
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First MileGourab Mitra
 
The story of language development
The story of language developmentThe story of language development
The story of language developmentHiroshi SHIBATA
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Nilesh Panchal
 

Semelhante a ruby-cocoa (20)

MacRuby & HotCocoa
MacRuby & HotCocoaMacRuby & HotCocoa
MacRuby & HotCocoa
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overview
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby Developers
 
RubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on RailsRubyStack: the easiest way to deploy Ruby on Rails
RubyStack: the easiest way to deploy Ruby on Rails
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPL
 
Mac ruby deployment
Mac ruby deploymentMac ruby deployment
Mac ruby deployment
 
Programming iOS in Lua - A bridge story
Programming iOS in Lua - A bridge storyProgramming iOS in Lua - A bridge story
Programming iOS in Lua - A bridge story
 
RubyMotion Introduction
RubyMotion IntroductionRubyMotion Introduction
RubyMotion Introduction
 
Why ruby
Why rubyWhy ruby
Why ruby
 
An introduction to the ruby ecosystem
An introduction to the ruby ecosystemAn introduction to the ruby ecosystem
An introduction to the ruby ecosystem
 
Ruby'izing iOS development
Ruby'izing iOS developmentRuby'izing iOS development
Ruby'izing iOS development
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Athens Ruby Meetup #3: IronRuby
Athens Ruby Meetup #3: IronRubyAthens Ruby Meetup #3: IronRuby
Athens Ruby Meetup #3: IronRuby
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 

Mais de tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

Mais de tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Último

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 

ruby-cocoa

  • 1. Intoduction to RubyCocoa (CocoaHead:Thinkboy) source: http://www.rubycocoa.com/
  • 2. Aganda • Problem? • What? • Why? • How? • Where? • Demo?
  • 3. Neither true or false, just a matter of choice!
  • 4. Problem? • I love Mac OSX GUI (Aqua) • I love Cocoa • I love Xcode & Interface Builder • But programming in Objective-C may be a bit of ‘curve’ to get started
  • 5. From Objective-C @interface Controller : NSObject { IBOutlet NSWindow *itsWindow; } - (IBAction)changeTransparency:(id)sender; @end @implementation Controller - (IBAction)changeTransparency:(id)sender { [itsWindow setAlphaValue:[sender floatValue]]; [itsWindow display]; } @end
  • 6. To RubyCocoa class Controller < OSX::NSObject ib_outlet :itsWindow def changeTransparency(sender) @itsWindow.setAlphaValue(sender.floatValue) @itsWindow.display end end
  • 7. Differences? • ruby vs many other programming lang • ruby vs objective-c vs java • more comparison • benchmark comparison Again, it is just a matter of choice and, perhaps, depending on requirement.
  • 8. What is Ruby? • Created by Yukihiro "Matz" Matsumoto in 1993 • PURE object-oriented “if it walks like a duck, and talks like a duck, then it might as well be a duck.” • Dynamic typing (duck typing) ~ Dave Thomas • Interpreted language (scripting language) • Designed for programmer productivity and fun • Follow the principle of least surprise (POLS) in short, when u look at the syntax, u feel like home. that’s all.
  • 9. Ruby Learning Trail • quick tutorial • interactive practice • Programming Ruby by Dave Thomas • Ruby Pocket Reference (O'Reilly 2007) • more recommendation
  • 10. When to use RubyCocoa? Ruby Ruby Domain Specific Application JRuby RubyCocoa Runtime Bridge Java Objective-C Core/ Framework C C System/Native
  • 11. What is RubyCocoa? • created by Hisakuni Fujimoto in 2001 • a bridge that makes it possible for Ruby scripts to access Objective-C objects • like SWIG? but better! Ruby and Objective C share a common ancestor in Smalltalk tool like SWIG which reads C and C++ source files and automatically • automatically create writes the glue code that Ruby proxy objects wraps C functions for other languages. Objective-C uses for that are bridged to Objective-C classes. dynamic message • forwards Ruby messages to the instances of Objective-C classes. by automatically creating Ruby proxy objects that are bridged • so what? mixing Ruby and Objective-C in to Objective-C classes. for wards Ruby messages to the instances of these the same source files. Objective-C classes.
  • 12. Why RubyCocoa? • officially supported by Apple • full support in Xcode3 (e.g. color syntax, auto complete, formatting) • supports all important features of Cocoa, such as key-value coding, key-value observing, Core Data, the document architecture, notifications, and undo management. • standard package in 10.5: ruby 1.8.6, rubycocoa, RubyGems, rake , Rails , Mongrel , Capistrano, Ferret, OpenID, sqlite3-ruby, libxml-ruby, dnssd, net-ssh and net-sftp
  • 13. RubyCocoa How-To? 1. install RubyCocoa 0.13.0 2. create Cocoa-Ruby Application in Xcode3 3. add ScriptingBridge.framework 4. create new ruby controller by subclass NSObject 5. create label and button 6. connect controller to ib_outlet & ib_action
  • 14. ITunesController.rb require 'osx/cocoa' include OSX class ITunesController < NSObject ib_outlet :text_field def show_version(sender) iTunes = SBApplication.applicationWithBundleIdentifier:'com.apple.iTunes' @text_field.setStringValue("iTunes version: #{iTunes.version}") end ib_action :show_version end
  • 15. Quick Tutorial? 1. This (Shortest) Tutorial: http://cocoalocker.blogspot.com/2007/11/ ruby-cocoa.html 2. Other Tutorial from YouTube http://www.youtube.com/watch?v=7q_DD- W6-oI&eurl=http://technorati.com/videos/ youtube.com%2Fwatch%3Fv%3D7q_DD- W6-oI
  • 16. RubyCocoa ri Doc? • install rubycocoa-0.13.0.tar manually. • ruby install config • ruby install doc • in the folder /RubyCocoa-0.13.0/ framework/bridge-doc/
  • 17. Where to Fish? • Warn! apple official doc is not so accurate!! • doc example does not work on Xcode3 • lets learn by example: • /Developer/Examples/Ruby/RubyCocoa • Must Read: official RubyCocoa site • Mailing list: rubycocoa-talk
  • 19. Demo Setup • RubyCocoa that remote control NXT • install Lego Mindstorms NXT 1.1 software • setup bluetooth device from Mac to NXT • gem install ruby-nxt 0.8.1 • download and compile ruby-serialport 0.6 • create a RubyCocoa apps in Xcode3 source: www.bluetooth.com + +
  • 20. Demo Architecture Ruby LabVIEW/C / Java Ruby-NXT NXT-G/RobotC/Lejos Bluetooth Ruby-SerialPort NXT Firmware
  • 21. NxtController.rb require 'osx/cocoa' class NxtController < OSX::NSObject ib_outlet :command_mode ib_outlet :run_state ib_outlet :tacho_count ib_action :move_forward def initialize @nxt = NXTComm.new($DEV) end def move_forward @command_mode.setStringValue("Moving forward...") command = Commands::Move.new(@nxt) command.ports = :a, :b, :c command.duration = {:seconds => 1} command.next_action = :brake @run_state.setStringValue("Run State: #{command.message1.inspect}") @tacho_count.setStringValue("Tacho Count: #{command.message2.inspect}") command.duration = :unlimited command.start sleep(1) command.stop end ..... * ported from the tk example of ruby-nxt
  • 22. More About NXT • NXT blog http://nxtasy.org/ • NXT programming Software http://www.teamhassenplug.org/NXT/ NXTSoftware.html • Interesting Projects http://www.youtube.com/watch?v=I8VvTENzPGI http://www.youtube.com/watch?v=0sl1Q6S3yuo http://www.youtube.com/watch?v=s0G35-xoRfA