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.
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(java_class, *args) ⇒ Object
-
#initialize ⇒ JRuby
constructor
A new instance of JRuby.
- #load_jars(jars) ⇒ Object
- #set_log_level(level) ⇒ Object
Constructor Details
#initialize ⇒ JRuby
Returns a new instance of JRuby.
75 76 77 78 79 |
# File 'lib/naether/java.rb', line 75 def initialize require 'java' @loaded_jars = [] end |
Instance Attribute Details
#loaded_jars ⇒ Object (readonly)
Returns the value of attribute loaded_jars.
73 74 75 |
# File 'lib/naether/java.rb', line 73 def loaded_jars @loaded_jars end |
Instance Method Details
#convert_to_ruby_array(java_array, to_string = false) ⇒ Object
108 109 110 |
# File 'lib/naether/java.rb', line 108 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
112 113 114 |
# File 'lib/naether/java.rb', line 112 def convert_to_ruby_hash( java_hash, to_string = false ) java_hash.to_hash end |
#create(java_class, *args) ⇒ Object
81 82 83 84 |
# File 'lib/naether/java.rb', line 81 def create( java_class, *args ) java_class = eval(java_class) java_class.new( *args ) end |
#load_jars(jars) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/naether/java.rb', line 90 def load_jars(jars) loaded_jars = [] unless jars.is_a? Array jars = [jars] end jars.each do |jar| = File.(jar) if !@loaded_jars.include? require loaded_jars << @loaded_jars << end end loaded_jars end |
#set_log_level(level) ⇒ Object
86 87 88 |
# File 'lib/naether/java.rb', line 86 def set_log_level( level ) com.slackworks.naether.LogUtil.changeLevel( 'com.slackworks', level ) end |