Module: Processing
- Defined in:
- lib/ruby-processing.rb,
lib/ruby-processing/app.rb,
lib/ruby-processing/runner.rb,
lib/ruby-processing/runners/base.rb,
lib/ruby-processing/runners/watch.rb,
lib/ruby-processing/exporters/creator.rb,
lib/ruby-processing/exporters/base_exporter.rb,
lib/ruby-processing/exporters/applet_exporter.rb,
lib/ruby-processing/exporters/application_exporter.rb
Overview
The top-level namespace, a home for all Ruby-Processing classes.
Defined Under Namespace
Modules: Proxy Classes: App, AppletExporter, ApplicationExporter, BaseExporter, Creator, Runner, Watcher
Constant Summary collapse
- VERSION =
[1,0,7]
- SKETCH_PATH =
ARGV[0]
- SKETCH_TEMPLATE =
For use with “bare” sketches that don’t want to define a class or methods
" class Sketch < Processing::App\n <% if has_methods %>\n <%= source %>\n <% else %>\n def setup\n size(DEFAULT_WIDTH, DEFAULT_HEIGHT, JAVA2D)\n <%= source %>\n no_loop\n end\n <% end %>\n end\n"
Class Method Summary collapse
-
.embedded? ⇒ Boolean
Are we embedded – inside the Processing IDE?.
-
.load_and_run_sketch ⇒ Object
This method is the common entry point to run a sketch, bare or complete.
-
.online? ⇒ Boolean
Are we online – inside an applet?.
-
.read_sketch_source ⇒ Object
Read in the sketch source code.
-
.version ⇒ Object
Returns the current version of Ruby-Processing.
Class Method Details
.embedded? ⇒ Boolean
Are we embedded – inside the Processing IDE?
30 31 32 |
# File 'lib/ruby-processing.rb', line 30 def self. ||= defined?(RP5_EMBEDDED) end |
.load_and_run_sketch ⇒ Object
This method is the common entry point to run a sketch, bare or complete.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby-processing/runners/base.rb', line 28 def self.load_and_run_sketch source = self.read_sketch_source has_sketch = !!source.match(/^[^#]*< Processing::App/) has_methods = !!source.match(/^[^#]*(def\s+setup|def\s+draw)/) if has_sketch load Processing::SKETCH_PATH Processing::App.sketch_class.new if !$app return else require 'erb' code = ERB.new(SKETCH_TEMPLATE).result(binding) Object.class_eval code, Processing::SKETCH_PATH, 0 Processing::App.sketch_class.new if !$app end end |
.online? ⇒ Boolean
Are we online – inside an applet?
25 26 27 |
# File 'lib/ruby-processing.rb', line 25 def self.online? @online ||= defined?(JRUBY_APPLET) end |
.read_sketch_source ⇒ Object
Read in the sketch source code. Needs to work both online and offline.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ruby-processing/runners/base.rb', line 47 def self.read_sketch_source if Processing.online? # Fuck the following lines. Fucking Java can go sit on broken glass. source = '' url = java.net.URL.new(JRUBY_APPLET.get_code_base, Processing::SKETCH_PATH) input = java.io.BufferedReader.new(java.io.InputStreamReader.new(url.open_stream)) while line = input.read_line do source << (line + "\n") if line end input.close else # Ahhh, much better. source = File.read(Processing::SKETCH_PATH) end source end |
.version ⇒ Object
Returns the current version of Ruby-Processing.
20 21 22 |
# File 'lib/ruby-processing.rb', line 20 def self.version VERSION.join('.') end |