rust 0.7 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rust-calls.rb DELETED
@@ -1,80 +0,0 @@
1
- require_relative 'rust-core'
2
-
3
- module Rust
4
- class Function
5
- attr_reader :name
6
- attr_reader :arguments
7
- attr_reader :options
8
-
9
- def initialize(name)
10
- @function = name
11
- @arguments = Arguments.new
12
- @options = Options.new
13
- end
14
-
15
- def options=(options)
16
- raise TypeError, "Expected Options" unless options.is_a?(Options)
17
-
18
- @options = options
19
- end
20
-
21
- def arguments=(arguments)
22
- raise TypeError, "Expected Arguments" unless options.is_a?(Arguments)
23
-
24
- @arguments = arguments
25
- end
26
-
27
- def to_R
28
- params = [@arguments.to_R, @options.to_R].select { |v| v != "" }.join(",")
29
- return "#@function(#{params})"
30
- end
31
-
32
- def call
33
- Rust._eval(self.to_R)
34
- end
35
- end
36
-
37
- class SimpleFormula
38
- def initialize(dependent, independent)
39
- @dependent = dependent
40
- @independent = independent
41
- end
42
-
43
- def to_R
44
- return "#@dependent ~ #@independent"
45
- end
46
- end
47
-
48
- class Variable
49
- def initialize(name)
50
- @name = name
51
- end
52
-
53
- def to_R
54
- @name
55
- end
56
- end
57
-
58
- class Arguments < Array
59
- def to_R
60
- return self.map { |v| v.to_R }.join(", ")
61
- end
62
- end
63
-
64
- class Options < Hash
65
- def to_R
66
- return self.map { |k, v| "#{k}=#{v.to_R}" }.join(", ")
67
- end
68
-
69
- def self.from_hash(hash)
70
- options = Options.new
71
- hash.each do |key, value|
72
- options[key.to_s] = value
73
- end
74
- return options
75
- end
76
- end
77
- end
78
-
79
- module Rust::RBindings
80
- end