class Optical::System

An Optical System is a set of Optical Elements, generally arranged in a line.

Attributes

elements[R]

@!attribute elements

@return [Array]  the set of elements in the system
spacing[RW]

@!attribute spacing

@return [Number]  the default spacing to add between newly added elements

Public Class Methods

new() click to toggle source
# File lib/optical/system.rb, line 19
def initialize
    @elements = []
end
spacer(space) click to toggle source

Convenience method for creating a new {Spacer}

# File lib/optical/system.rb, line 15
def self.spacer(space)
    Spacer::new(space)
end

Public Instance Methods

push(element) click to toggle source

Append a new Optical element @return [System]

# File lib/optical/system.rb, line 25
def push(element)
    if element.is_a?(Numeric)
        @elements.push Spacer.new(element)
    elsif element.is_a?(Spacer)
        @elements.push element
    else
        @elements.push Spacer.new(spacing) if spacing && !(elements.empty? || elements.last.is_a?(Spacer))
        @elements.push element
    end

    self
end