Class: Grope::WSOWrapper
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/grope/wso_wrapper.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of WSOWrapper.
39
40
41
|
# File 'lib/grope/wso_wrapper.rb', line 39
def initialize(wso)
@wso = wso
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/grope/wso_wrapper.rb', line 55
def method_missing(name, *args)
args = unwrap_arguments(args)
result = nil
begin
if name.to_s =~ /^(apply|call|toString)$/
result = @wso.callWebScriptMethod_withArguments(name, args)
else
result = @wso.__send__(name, *args)
end
rescue
result = @wso.valueForKey(name)
end
if WebScriptObject === result &&
result.callWebScriptMethod_withArguments(:toString, []).to_s =~ /^function/
self.class.wrap(result.callWebScriptMethod_withArguments(:call, [@wso] + args))
else
self.class.wrap(result)
end
end
|
Instance Attribute Details
#wso ⇒ Object
Returns the value of attribute wso.
10
11
12
|
# File 'lib/grope/wso_wrapper.rb', line 10
def wso
@wso
end
|
Class Method Details
.wrap(value) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/grope/wso_wrapper.rb', line 12
def self.wrap(value)
if value.respond_to?(:bool?) && value.bool?
return value.boolValue
end
case value
when nil
nil
when WSOWrapper
value
when Integer
value
when OSX::NSCFBoolean
value.boolValue
when OSX::NSNumber
value.integer? ? value.to_i : value.to_f
when OSX::NSCFNumber
value.integer? ? value.to_i : value.to_f
when OSX::NSMutableString
value.to_s
when OSX::NSCFString
value.to_s
else
new(value)
end
end
|
Instance Method Details
#each ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/grope/wso_wrapper.rb', line 47
def each
i = 0
while i < size
yield self[i]
i += 1
end
end
|
#size ⇒ Object
43
44
45
|
# File 'lib/grope/wso_wrapper.rb', line 43
def size
length
end
|