Class: Naether::Java::JRuby
- Inherits:
-
Object
- Object
- Naether::Java::JRuby
- Includes:
- Singleton
- Defined in:
- lib/naether/java.rb
Overview
Handle loading jars for JRuby
Instance Attribute Summary collapse
-
#loaded_jars ⇒ Object
readonly
Returns the value of attribute loaded_jars.
-
#loaded_paths ⇒ Object
readonly
Returns the value of attribute loaded_paths.
Instance Method Summary collapse
- #convert_to_ruby_array(java_array, to_string = false) ⇒ Object
- #convert_to_ruby_hash(java_hash, to_string = false) ⇒ Object
- #create(target_class, *args) ⇒ Object
-
#initialize ⇒ JRuby
constructor
A new instance of JRuby.
- #java_class(target_class) ⇒ Object
- #load_jars(jars) ⇒ Object
- #load_paths(paths) ⇒ Object
Constructor Details
#initialize ⇒ JRuby
Returns a new instance of JRuby.
84 85 86 87 88 89 |
# File 'lib/naether/java.rb', line 84 def initialize require 'java' @loaded_jars = [] @loaded_paths = [] end |
Instance Attribute Details
#loaded_jars ⇒ Object (readonly)
Returns the value of attribute loaded_jars.
82 83 84 |
# File 'lib/naether/java.rb', line 82 def loaded_jars @loaded_jars end |
#loaded_paths ⇒ Object (readonly)
Returns the value of attribute loaded_paths.
82 83 84 |
# File 'lib/naether/java.rb', line 82 def loaded_paths @loaded_paths end |
Instance Method Details
#convert_to_ruby_array(java_array, to_string = false) ⇒ Object
136 137 138 |
# File 'lib/naether/java.rb', line 136 def convert_to_ruby_array( java_array, to_string = false ) java_array.to_a end |
#convert_to_ruby_hash(java_hash, to_string = false) ⇒ Object
140 141 142 |
# File 'lib/naether/java.rb', line 140 def convert_to_ruby_hash( java_hash, to_string = false ) java_hash.to_hash end |
#create(target_class, *args) ⇒ Object
91 92 93 94 |
# File 'lib/naether/java.rb', line 91 def create( target_class, *args ) java_class = java_class(target_class) java_class.new( *args ) end |
#java_class(target_class) ⇒ Object
96 97 98 |
# File 'lib/naether/java.rb', line 96 def java_class( target_class ) eval(target_class) end |
#load_jars(jars) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/naether/java.rb', line 118 def load_jars(jars) load_jars = [] unless jars.is_a? Array jars = [jars] end jars.each do |jar| = File.(jar) if !@loaded_jars.include? require load_jars << @loaded_jars << end end load_jars end |
#load_paths(paths) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/naether/java.rb', line 100 def load_paths(paths) load_paths = [] unless paths.is_a? Array paths = [paths] end paths.each do |path| = File.(path) if !@loaded_paths.include? $CLASSPATH << load_paths << @loaded_paths << end end load_paths end |