Module: Linear1

Defined in:
lib/linear1/graph.rb,
lib/linear1/system.rb,
lib/linear1/standard.rb,
lib/linear1/function.rb,
lib/linear1/point_slope.rb,
lib/linear1/slope_intercept.rb,
lib/linear1/direct_variation.rb,
lib/linear1/arithmetic_sequence.rb

Defined Under Namespace

Classes: ArithmeticSequence, DirectVariation, Function, Graph, PointSlope, SlopeIntercept, Standard, System

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.DirectVariation(object) ⇒ Object



16
17
18
19
# File 'lib/linear1/direct_variation.rb', line 16

def DirectVariation object
	if object.is_kind_of? Numeric then DirectVariation.new
	else DirectVariation.try_convert object end
end

.Function(*args) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/linear1/function.rb', line 93

def Function(*args)
	Function.new *args
rescue
	args.each do |arg|
		case arg
			when ->(a) {a.respond_to? :to_function} then arg.to_function
			when ->(a) {a.respond_to? :to_ary and a.to_ary.size == 0..3 and a.to_ary.all} then Function.new *arg.to_ary
		else
			fail TypeError, "Could not convert #{arg.inspect} to Function"
		end
	end
end

.SlopeIntercept(*args) ⇒ Object



26
27
28
29
30
31
# File 'lib/linear1/slope_intercept.rb', line 26

def SlopeIntercept(*args) # @see SlopeIntercept.new, SlopeIntercept.try_convert
	case args.length
		when 1 then SlopeIntercept.try_convert *args
		when 2 then SlopeIntercept.new *args
	else fail ArgumentError, "Expected 1..2 arguments. Got #{args.length}" end
end

.Standard(*args) ⇒ Object

See Also:

  • Standard.new


45
46
47
48
49
50
# File 'lib/linear1/standard.rb', line 45

def Standard(*args) # @see Standard.try_convert, Standard.new
	case args.length
		when 1 then Standard.new *args 
		when 3 then Standard.try_convert object
	else fail ArgumentError, "Expected 1 or 3 arguments. Got #{args.length}" end
end

Instance Method Details

#PointSlope(*object) ⇒ Object



27
28
29
30
31
32
# File 'lib/linear1/point_slope.rb', line 27

def PointSlope(*object)
	case object.length
		when 1 then PointSlope.try_convert(*object)
		when 3 then PointSlope.new(*object)
	else raise ArgumentError, "Expected 1 or 3 arguments. Got #{object.length}" end
end