Your SlideShare is downloading. ×
0
learning to walk
    in shoes

   brian hogan
info@napcs.com
twitter: bphogan
brian who?
Shoes?
OMG! SHOES!




x-platform GUI in Ruby!
_why_ ruby?

• Highly dynamic
• Very high level
• 100% object oriented
• 100% open-source
data types in ruby
variables
Constants



Local variable


Instance variable
Ruby is
dynamically typed
don’t confuse that with
      weak typed!
a type can be defined
      explicitly
or implicitly
...but a string and a
number can’t just be
   mashed together
     without help.
bad
better
awesome.


    #{} embeds an
 expression in a string,
converting the result to
       a string!
you’re going to see
        #{}
       a lot.
ruby has simple logic
defining methods
ruby has some
 simple rules
everything is
  an object
every statement
returns a value.
everything evaluates
  to TRUE except
   nil and FALSE.
everything is an object.
  everything is a class.
classes can be boring or
        awesome.
booooooring
awesome.
as you write ruby
you often see code
 that writes code.
arrays and hashes are
important. Pay attention.
arrays
hash
whenever you see

         =>

you’re dealing with a
        hash.
methods that take
hashes as parameters
   are very, very
     common.
this method
takes one parameter.
now let’s
   take a walk
around the Block
blocks let us loop
so, a regular class...
...can be improved with blocks
make constructors
 accept hashes...
...and use a block to
 iterate over keys and
values to assign instance
        variables.
this technique
makes writing DSLs
        easy.
no. wrong.
Domain
 Specific
Language
ruby has “sugar” to
make it easy to read.
oh yeah...

= is assignment.

 == is equality.
ok now you’re
 warmed up.
but you have to
  Tie your Shoes
before you can run!
Shoes is a DSL.
a Shoes app is a ruby
      object.
your code lives inside of
this object using blocks.
it’s super easy.
REALLY super easy.
so, basic stuff.
Shoes.app
background
background
backgrounds can use
   hex codes too.
layout works like
 you wish HTML
 and CSS works
stacks
all sub elements stack.
flows
all sub elements flow
combine stacks
    and flows
to make complex
     layouts
two column with header
the Shoes
window is also
    a flow.
simple text
edit_line
edit_line




great for passwordz
edit_box
list_box




arrays and hashes are
    everywhere.
radio
check
use instance variables
to reference controls.
grabbing and showing
        input
any object is fair game.
 even stacks and floats
append to a stack
Clearing a stack
Windows
windows are
like new apps.
each screen
  is a url.
urls and methods
shoes can
 play music
and movies...
load images...
...and open URLs in
      browsers.
you can use any gem
    with Shoes.
shoes can install
libraries for you.
you can also
access OS stuff.
demos
http://github.com/napcs/shoes_demo_apps/
questions?
  info@napcs.com
   twitter: bphogan
http://www.napcs.com/
Learning To Walk In Shoes
Learning To Walk In Shoes
Learning To Walk In Shoes
Upcoming SlideShare
Loading in...5
×

Learning To Walk In Shoes

2,536

Published on

Presentation slides and notes from my April 4th talk on Shoes, the cross-platform GUI framework written in Ruby.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,536
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
32
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

  • So, who is this guy?
    Visit http://www.napcs.com/
    http://www.snippetstash.com/
    http://www.feelmyskills.com/
    http://www.webdesignfordevelopers.com
  • A talk about shoes would be completely inappropriate at a code camp. So we’re not talking about these kinds of shoes. Although, a search for shoes on Google will turn up lots of stuff like this.
  • We’re talking about Shoes, a cross-platform framework for making GUI apps, using the Ruby language.
  • It’s also incredibly easy to learn.
  • One of the nice things about Ruby is that it strives to be easy to read. Here, we’re declaring some variables and setting values.
  • Like most languages, you’ve got constants, local variables, and instance variables. The convention in Ruby is to use all capital letters for constants, but anything that starts with a capital letter is considered constant.

    You can actually change values of constants at runtime, but you will get a warning about that.

    Instance variables get the @ sign.
  • Anyone know what dynamically typed is?

    What’s the opposite of dynamically typed?




  • You’ll get a runtime error because you can’t add a string to a number
  • The to_s method converts many types of objects to strings.
  • You can embed any expression this way and it will automatically cast the value to a string, even if it’s a null value.


  • def is so much nicer than function.

  • There’s no such thing as a primitive in Ruby. Even a string or an integer is an object.
  • With methods, if it’s not explicit with a return, then the return value is the value of the last statement.
  • 1 is true. 0 is not false.

  • The “java” way. This is on the way out because it’s stupid. Here we’re declaring instance variables, getters, and setters. Essentially creating properties.
  • attr_accessor creates variables, getters, and setters.
  • Metaprogramming!
  • They’re everywhere.
  • Square brackets denote hashes.
  • Curly braces and => are for hashes.
  • Hashrocket.

  • Only one parameter which is a hash. Hashes are amazing because you can actually send the parameters into a method in any order, and it’s nicely self-documenting. No referencing the api to figure out which parameter is the width.
  • Blocks are like closures or anonymous fuctions
  • We can use them for looping instead of having to track an array or hash position.

  • This is a standard pattern in Ruby classes.
  • Obligatory LOLCAT is obligatory!





  • Parenthesis are optional in many cases, especially when it’s obvious.


  • you’re supposed to BOO!
  • and no, this doesn’t excuse the bad joke.


























  • Use the .text method to grab the text from the textbox.

  • The @names section contains the names we add, and names get added when we click the button.
  • Stacks and flows can be cleared as well. Clear can take a block which you can use to place new content in the stack or flow.

  • So instance variables are isolated.

  • We can use a nice MVC-style structure here. Notice that we can wrap blocks in methods so we can easily call them.
  • The video player plays mp3s, oggs, avis, movs, flvs and more.


  • There are hundreds of libraries out there for doing pretty much anything. Twitter, Youtube, Flickr, Last.fm, and anything in between.
  • When the app starts, these libraries get installed to the user’s home directory.

  • Accessing standard dialogs and the clipboard is pretty simple.

  • Either check it out with git or click the download link and unzip the package.

  • Transcript of "Learning To Walk In Shoes"

    1. 1. learning to walk in shoes brian hogan info@napcs.com twitter: bphogan
    2. 2. brian who?
    3. 3. Shoes?
    4. 4. OMG! SHOES! x-platform GUI in Ruby!
    5. 5. _why_ ruby? • Highly dynamic • Very high level • 100% object oriented • 100% open-source
    6. 6. data types in ruby
    7. 7. variables Constants Local variable Instance variable
    8. 8. Ruby is dynamically typed
    9. 9. don’t confuse that with weak typed!
    10. 10. a type can be defined explicitly
    11. 11. or implicitly
    12. 12. ...but a string and a number can’t just be mashed together without help.
    13. 13. bad
    14. 14. better
    15. 15. awesome. #{} embeds an expression in a string, converting the result to a string!
    16. 16. you’re going to see #{} a lot.
    17. 17. ruby has simple logic
    18. 18. defining methods
    19. 19. ruby has some simple rules
    20. 20. everything is an object
    21. 21. every statement returns a value.
    22. 22. everything evaluates to TRUE except nil and FALSE.
    23. 23. everything is an object. everything is a class. classes can be boring or awesome.
    24. 24. booooooring
    25. 25. awesome.
    26. 26. as you write ruby you often see code that writes code.
    27. 27. arrays and hashes are important. Pay attention.
    28. 28. arrays
    29. 29. hash
    30. 30. whenever you see => you’re dealing with a hash.
    31. 31. methods that take hashes as parameters are very, very common.
    32. 32. this method takes one parameter.
    33. 33. now let’s take a walk around the Block
    34. 34. blocks let us loop
    35. 35. so, a regular class...
    36. 36. ...can be improved with blocks
    37. 37. make constructors accept hashes...
    38. 38. ...and use a block to iterate over keys and values to assign instance variables.
    39. 39. this technique makes writing DSLs easy.
    40. 40. no. wrong.
    41. 41. Domain Specific Language
    42. 42. ruby has “sugar” to make it easy to read.
    43. 43. oh yeah... = is assignment. == is equality.
    44. 44. ok now you’re warmed up.
    45. 45. but you have to Tie your Shoes before you can run!
    46. 46. Shoes is a DSL.
    47. 47. a Shoes app is a ruby object.
    48. 48. your code lives inside of this object using blocks.
    49. 49. it’s super easy.
    50. 50. REALLY super easy.
    51. 51. so, basic stuff.
    52. 52. Shoes.app
    53. 53. background
    54. 54. background
    55. 55. backgrounds can use hex codes too.
    56. 56. layout works like you wish HTML and CSS works
    57. 57. stacks
    58. 58. all sub elements stack.
    59. 59. flows
    60. 60. all sub elements flow
    61. 61. combine stacks and flows to make complex layouts
    62. 62. two column with header
    63. 63. the Shoes window is also a flow.
    64. 64. simple text
    65. 65. edit_line
    66. 66. edit_line great for passwordz
    67. 67. edit_box
    68. 68. list_box arrays and hashes are everywhere.
    69. 69. radio
    70. 70. check
    71. 71. use instance variables to reference controls.
    72. 72. grabbing and showing input
    73. 73. any object is fair game. even stacks and floats
    74. 74. append to a stack
    75. 75. Clearing a stack
    76. 76. Windows
    77. 77. windows are like new apps.
    78. 78. each screen is a url.
    79. 79. urls and methods
    80. 80. shoes can play music and movies...
    81. 81. load images...
    82. 82. ...and open URLs in browsers.
    83. 83. you can use any gem with Shoes.
    84. 84. shoes can install libraries for you.
    85. 85. you can also access OS stuff.
    86. 86. demos
    87. 87. http://github.com/napcs/shoes_demo_apps/
    88. 88. questions? info@napcs.com twitter: bphogan http://www.napcs.com/
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×