Class: Fityk::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/fityk/engine.rb

Overview

The Engine class encapsulates a single connection to a Fityk instance. Usage:

require 'fityk'

fityk = Fityk::Engine.new
fityk.get_info("version", true).split("\n")

fityk.load_data 0, [1,2,3], [4,5,6], [7,8,9]
fityk.get_data.entries.first
fityk.get_data.entries.first.x
fityk.get_data.entries.first.y
fityk.get_data.entries.first.sigma

Values are sent to and from Fityk by calling a method on the engine with the method name of interest.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Engine

Create a new Engine object that connects to Fityk via the given driver



27
28
29
30
31
# File 'lib/fityk/engine.rb', line 27

def initialize(options = {})
  load_driver(options[:driver])
  
  @handle = @driver.open(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args) ⇒ Object

Call Fityk passing in the arguments



34
35
36
# File 'lib/fityk/engine.rb', line 34

def method_missing(method_id, *args)
  @driver.call(@handle, method_id, *args)
end

Instance Attribute Details

#driverObject (readonly)

A reference to the underlying Fityk driver used by this engine.



24
25
26
# File 'lib/fityk/engine.rb', line 24

def driver
  @driver
end

#handleObject (readonly)

The low-level opaque engine handle that this object wraps.



21
22
23
# File 'lib/fityk/engine.rb', line 21

def handle
  @handle
end