This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def to_camel_case(str) | |
| h, *t = *str.split(/[\W_]/) | |
| str.empty? ? '' : (h ||= '') << t.map(&:capitalize).join | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Car { | |
| public String brand; | |
| public int year; | |
| public Car(String brand, int year) { | |
| this.brand = brand; | |
| this.year = year; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Mystery { | |
| public Mystery() { | |
| int a = 0; | |
| { | |
| int b = 7; | |
| a = b; | |
| } | |
| int b; | |
| System.out.println(a + " , " + b); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Listener | |
| def on(*types, &blk) | |
| types.each do |type| | |
| (self.listeners[type] ||= []) << blk | |
| end | |
| end | |
| def trigger(event) | |
| return unless self.listeners[event.type] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Kaffeh | |
| class Config | |
| def initialize(cfg) | |
| self.path = cfg | |
| load | |
| end | |
| def path=(path) | |
| if File.exists?(path) and File.file?(path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module JSON | |
| def self.dump(object, io=nil, limit=nil) | |
| state = {} | |
| state[:max_nesting] = limit if limit | |
| begin | |
| js = JSON.generate(object, nil, state) | |
| rescue JSON::NestingError | |
| raise ArgumentError, "exceed depth limit" | |
| end | |
| if io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Kaffeh | |
| class Config | |
| attr_accessor :title, :width, :height | |
| def initialize(title = "Kaffeh", width = 600, height = 480) | |
| @title = title | |
| @width = width | |
| @height = height | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## main.rb | |
| def Kaffeh::init | |
| end | |
| def Kaffeh::update(delta) | |
| end | |
| def Kaffeh::draw | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MBPro2012:kaffeh felix$ make mrb | |
| mrbc -o data.mrb src/ruby/kaffeh.rb src/ruby/main.rb src/ruby/vec.rb | |
| src/ruby/vec.rb:0:9: syntax error, unexpected keyword_module, expecting $end | |
| make: *** [mrb] Error 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require './kaffeh/kaffeh' | |
| def Kaffeh::init | |
| end | |
| def Kaffeh::update(delta) | |
| end | |
| def Kaffeh::draw | |
| end |