Class: Appscript::GenericReference

Inherits:
AS_SafeObject show all
Defined in:
lib/rb-scpt.rb

Overview

GENERIC REFERENCE

Direct Known Subclasses

GenericApplication

Constant Summary

Constants inherited from AS_SafeObject

AS_SafeObject::EXCLUDE

Instance Method Summary collapse

Methods inherited from AS_SafeObject

hide

Constructor Details

#initialize(call) ⇒ GenericReference

Returns a new instance of GenericReference.



302
303
304
305
# File 'lib/rb-scpt.rb', line 302

def initialize(call)
  super()
  @_call = call
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



317
318
319
# File 'lib/rb-scpt.rb', line 317

def method_missing(name, *args)
  return Appscript::GenericReference.new(@_call + [[name, args]])
end

Instance Method Details

#==(v) ⇒ Object Also known as: eql?



307
308
309
# File 'lib/rb-scpt.rb', line 307

def ==(v)
  return (self.class == v.class and @_call == v._call)
end

#AS_resolve(app_data) ⇒ Object



345
346
347
348
349
350
351
# File 'lib/rb-scpt.rb', line 345

def AS_resolve(app_data)
  ref = Reference.new(app_data, {'app' => AEM.app, 'con' => AEM.con, 'its' => AEM.its}[@_call[0]])
  @_call[1, @_call.length].each do |name, args|
    ref = ref.send(name, *args)
  end
  return ref
end

#hashObject



313
314
315
# File 'lib/rb-scpt.rb', line 313

def hash
  return @_call.hash
end

#inspectObject



341
342
343
# File 'lib/rb-scpt.rb', line 341

def inspect
  return to_s
end

#to_sObject



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/rb-scpt.rb', line 321

def to_s
  s= @_call[0]
  @_call[1, @_call.length].each do |name, args|
    if name == :[]
      if args.length == 1
        s += "[#{args[0].inspect}]"
      else
        s += "[#{args[0].inspect}, #{args[1].inspect}]"
      end
    else
      if args.length > 0
        s += ".#{name.to_s}(#{(args.map { |arg| arg.inspect }).join(', ')})"
      else
        s += ".#{name.to_s}"
      end
    end
  end
  return s
end