Module: Mlr

Defined in:
lib/mlr.rb,
lib/mlr/version.rb,
lib/mlr/strategy/python.rb

Defined Under Namespace

Modules: Strategy Classes: AnchorPoint2D, AnchorPoint3D, Error, ResultPoint2D, ResultPoint3D

Constant Summary collapse

MODE2D =

modes

'2D'.freeze
MODE3D =
'3D'.freeze
SOLVER_LSE =

sorvers

'LSE'.freeze
PYTHON =

STRATEGIES

'python'.freeze
STRATEGY =
PYTHON
DETECT_MODE =
->(points) {
  if points.all? { |point| point.is_a?(Mlr::AnchorPoint2D) }
    Mlr::MODE2D
  elsif points.all? { |point| point.is_a?(Mlr::AnchorPoint3D) }
    Mlr::MODE3D
  end
}
VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.from_array(array) ⇒ Object

interface



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mlr.rb', line 45

def self.from_array(array)
  points = array.map do |line|
    case line.size
    when 3 then Mlr::AnchorPoint2D.new(*line)
    when 4 then Mlr::AnchorPoint3D.new(*line)
    else
      raise 'wrong number of elements in array'
    end
  end

  from_points(points)
end

.from_points(points) ⇒ Object



58
59
60
# File 'lib/mlr.rb', line 58

def self.from_points(points)
  strategy.get_point(points: points, mode: DETECT_MODE.call(points))
end

.strategyObject

strategy selector



38
39
40
41
42
# File 'lib/mlr.rb', line 38

def self.strategy
  case STRATEGY
  when PYTHON then Mlr::Strategy::Python
  end
end