SlideShare a Scribd company logo
1 of 23
Download to read 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

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 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
 

Similar to 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...
 

More from 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
 

More from 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
 

Recently uploaded

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingSelcen Ozturkcan
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

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