71
72
73
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
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/stupidedi/versions/functional_groups/003010/element_types/operators.rb', line 71
def relational_operators(*ops)
file, line, = Stupidedi.caller
if ops.last.is_a?(Hash)
options = ops.pop
case options[:coerce]
when String, Symbol
coerce = options[:coerce]
else
raise ArgumentError,
"must pass :coerce => :method"
end
else
raise ArgumentError,
"must pass :coerce => :method"
end
ops.each do |op|
class_eval(" def \#{op}(other, &block)\n begin\n value.\#{op}(other.\#{coerce}, &block)\n rescue NoMethodError\n begin\n me, he = other.coerce(self)\n me.\#{op}(he, &block)\n rescue NoMethodError\n raise TypeError,\n \"cannot coerce \\\#{other.class} to \\\#{self.class}\"\n end\n end\n end\n RUBY\n end\nend\n", file, line.to_i - 1)
|