Class: CA::Interp

Inherits:
Object
  • Object
show all
Defined in:
lib/carray/math/interp.rb

Defined Under Namespace

Classes: Adapter, CAInterp1D, GSLSpline

Constant Summary collapse

ADAPTERS =
{}

Instance Method Summary collapse

Constructor Details

#initialize(type, scales, value, options = {}) ⇒ Interp

Returns a new instance of Interp.



19
20
21
22
23
24
25
26
27
# File 'lib/carray/math/interp.rb', line 19

def initialize (type, scales, value, options={})
  adapter_class = ADAPTERS[type]
  if adapter_class
    @type    = type
    @adapter = adapter_class.new(scales, value, options)
  else
    raise RuntimeError, "unknown interp adapter <#{type}>"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args) ⇒ Object



33
34
35
# File 'lib/carray/math/interp.rb', line 33

def method_missing (id, *args)
  return @adapter.send(id, *args)
end

Instance Method Details

#[](*args) ⇒ Object



29
30
31
# File 'lib/carray/math/interp.rb', line 29

def [] (*args)
  return @adapter.evaluate(*args)
end