SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie Introduction to RubyCocoa GUI Programming

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. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLMario-Leander Reimer
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureQAware GmbH
 
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
 

Ähnlich wie Introduction to RubyCocoa GUI Programming (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. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPL
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
 
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...
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
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
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
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
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
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
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 

Kürzlich hochgeladen (20)

React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
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
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
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
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
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
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 

Introduction to RubyCocoa GUI Programming

  • 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