The first two days of the training were really excellent. Great pace, clear explanations and samples, very technical, Chad and Dave really rock at Ruby.
We start with a discussion on DSL versus an API.
Example is Rake. Rake is a dependency oriented programming language.
Eexample from Dhaka (a paraser generator)
outputs:
#<CommandListener:0x80264 @commands= [[:you, CommandListener], [:whatever, #<CommandListener:0x80264 ...>], [:accepts, #<CommandListener:0x80264 ...>], [:object, #<CommandListener:0x80264 ...>], [:this, #<CommandListener:0x80264 ...>], [:it], [:stores, #<CommandListener:0x80264 ...>]]>
outputs:
#<CommandListener:0x712b4 @commands= [[:this], [:object], [:accepts], [:whatever], [:commands], [:and], [:stores], [:it]]>
Note any keyword can be used with method_missing…E.g. freeze is not a missing method.
Now by using a BlankSlate object we can avoid this issue:
We can now create a command listener that can use any commands:
And we get the following output:
[[:freeze!], [:type, #<CommandListener:0x7ee28>], [:even, #<CommandListener:0x7ee28>], [:can, #<CommandListener:0x7ee28>], [:You, #<CommandListener:0x7ee28>]]
On the same principals we just create a morse encoder, and of course Dave had to show off and interface with the speech function of OSX and another version that interfaces with the MIDI controller.
Creating a loop with continuations
We voted on what to cover next as we won’t have time to cover every thing…and the winners are:
* Concurrency .................. * Debugging/Profiling ................ * JRuby ...... * Ruby Extras ........... * Distributed Programming ......................
Marshaling
>> h = {:x => 1}
>> Marshal.dump(h)
=> “\004\b{\006:\006xi\006”
>> Marshal.load(_)
=> {:x=>1}
DRB Server
DRb Client
require ‘drb’
o = DRbOject.new_with_url(“druby:’’localhost:4321”)
o.last_accessed = Time.now
o.some_other_arbitrary_method = “Set this on the open struct”
By default Pass-by-value, but can be Pass-by-reference can be enabled by including DRbUndumped.
…
That’s all Folk! …my hands/brain where running tired during the last hour :-)
That was an incredible 3 days thanks to Chad and Dave. So if you want to dive deeper in Ruby, the Advanced Ruby is the best way to get there!
Enjoy!
Daniel