Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/project/ext/object.rb
Instance Method Summary collapse
- #app ⇒ Object
- #blank? ⇒ Boolean
-
#caller ⇒ Object
REMOVE when RubyMotion adds this.
- #device ⇒ Object
-
#find(*args) ⇒ Object
Do not alias this, strange bugs happen where classes don’t have methods.
-
#find!(*args) ⇒ Object
Do not alias this, strange bugs happen where classes don’t have methods.
- #inspect ⇒ Object
-
#mp(s, opts = {}) ⇒ Object
REMOVE when mp starts working.
-
#object_id ⇒ Object
REMOVE when RubyMotion adds this.
-
#rmq(*working_selectors) ⇒ Object
RMQ stuff.
- #short_class_name ⇒ Object
Instance Method Details
#app ⇒ Object
103 104 105 |
# File 'lib/project/ext/object.rb', line 103 def app rmq.app end |
#blank? ⇒ Boolean
49 50 51 |
# File 'lib/project/ext/object.rb', line 49 def blank? self.respond_to?(:empty?) ? self.empty? : !self end |
#caller ⇒ Object
REMOVE when RubyMotion adds this
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/project/ext/object.rb', line 9 def caller out = "caller:" stacktrace = Java::Lang::Thread.currentThread.getStackTrace stacktrace.each_with_index do |trc, i| klass_name = trc.className method_name = trc.methodName next if klass_name == "com.rubymotion.ReplTask" next if method_name == "getStackTrace" || method_name == "getThreadStackTrace" line_number = trc.getLineNumber out << "\n " #out << " " * i if line_number < 0 out << " " else out << line_number.to_s.ljust(4) end out << " " out << method_name.to_s.ljust(30) out << " " out << klass_name.to_s end mp out end |
#device ⇒ Object
107 108 109 |
# File 'lib/project/ext/object.rb', line 107 def device rmq.device end |
#find(*args) ⇒ Object
Do not alias this, strange bugs happen where classes don’t have methods
63 64 65 |
# File 'lib/project/ext/object.rb', line 63 def find(*args) # Do not alias this, strange bugs happen where classes don't have methods rmq(*args) end |
#find!(*args) ⇒ Object
Do not alias this, strange bugs happen where classes don’t have methods
67 68 69 |
# File 'lib/project/ext/object.rb', line 67 def find!(*args) # Do not alias this, strange bugs happen where classes don't have methods rmq(*args).get end |
#inspect ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/project/ext/object.rb', line 37 def inspect if self.respond_to?(:id) "<#{short_class_name}|#{id}>" else "<#{short_class_name}|#{object_id}>" end end |
#mp(s, opts = {}) ⇒ Object
REMOVE when mp starts working
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/project/ext/object.rb', line 74 def mp(s, opts={}) if opts[:debugging_only] return unless RMQ.debugging? end @@mp_backspace ||= "\b\b " * (Android::App::Application.name.length + 20) if s.nil? s = "<nil>" #elsif s.is_a?(Array) # TODO - THIS DOESN'T WORK #s = s.map{|e| e.inspect }.join("\n") else s = s.to_s end lines = s.split("\n") @@mp_tproc ||= proc do |line| # This hack fixes RMA bug, TODO remove when RMA block retention bug is fixed #if RMQ.debugging? #out = @@mp_backspace #out << "\e[1;#{36}m#{self.object_id}\e[0m #{self.short_class_name}".ljust(50) #out << " \e[1;#{34}m#{line}\e[0m" #puts out #else puts "#{@@mp_backspace} \e[1;#{34}m#{line}\e[0m" #end end lines.each &@@mp_tproc end |
#object_id ⇒ Object
REMOVE when RubyMotion adds this
4 5 6 |
# File 'lib/project/ext/object.rb', line 4 def object_id Java::Lang::System.identityHashCode(self) end |
#rmq(*working_selectors) ⇒ Object
RMQ stuff
55 56 57 58 59 60 61 |
# File 'lib/project/ext/object.rb', line 55 def rmq(*working_selectors) if (app = RMQ.app) && ((cvc = app.current_screen) || (cvc = app.current_activity)) cvc.rmq(working_selectors) else RMQ.create_with_array_and_selectors([], working_selectors, self) end end |
#short_class_name ⇒ Object
45 46 47 |
# File 'lib/project/ext/object.rb', line 45 def short_class_name self.class.name.split('.').last end |