Class: EleetScript::EleetToRubyWrapper
- Inherits:
-
Object
- Object
- EleetScript::EleetToRubyWrapper
show all
- Defined in:
- lib/engine/eleet_to_ruby_wrapper.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of EleetToRubyWrapper.
3
4
5
6
|
# File 'lib/engine/eleet_to_ruby_wrapper.rb', line 3
def initialize(eleet_obj, engine)
@eleet_obj = eleet_obj
@engine = engine
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/engine/eleet_to_ruby_wrapper.rb', line 14
def method_missing(name, *args, &block)
if args && args.length > 0
call(name, *args, &block)
else
call(name, &block)
end
end
|
Instance Method Details
#call(method, *args, &block) ⇒ Object
8
9
10
11
12
|
# File 'lib/engine/eleet_to_ruby_wrapper.rb', line 8
def call(method, *args, &block)
eleet_args = args.map { |a| to_eleet_value(a) }
eleet_args << to_eleet_value(block) if block_given?
to_ruby_value(@eleet_obj.call(method, eleet_args))
end
|
#class(orig = false) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/engine/eleet_to_ruby_wrapper.rb', line 26
def class(orig = false)
if orig
super
else
call(:class_ref)
end
end
|
#inspect ⇒ Object
51
52
53
|
# File 'lib/engine/eleet_to_ruby_wrapper.rb', line 51
def inspect
"<EleetToRubyWrapper wrapping=#{call(:class_name)}>"
end
|
#raw ⇒ Object
22
23
24
|
# File 'lib/engine/eleet_to_ruby_wrapper.rb', line 22
def raw
@eleet_obj
end
|
#to_h ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/engine/eleet_to_ruby_wrapper.rb', line 34
def to_h
if call(:responds_to?, :to_list)
list_hash = call(:to_list).raw.ruby_value.to_h
{}.tap do |hash|
list_hash.each do |key, value|
hash[to_ruby_value(key)] = to_ruby_value(value)
end
end
else
{}
end
end
|
#to_s ⇒ Object
47
48
49
|
# File 'lib/engine/eleet_to_ruby_wrapper.rb', line 47
def to_s
call(:to_string)
end
|