Class: EpiMath::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/epimath100/function.class.rb

Direct Known Subclasses

Polynomial, Rational

Instance Method Summary collapse

Instance Method Details

#calc(x) ⇒ Object



16
17
18
# File 'lib/epimath100/function.class.rb', line 16

def calc x
  return 0
end

#convert_hash(hash) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/epimath100/function.class.rb', line 20

def convert_hash hash
  coef = []
  hash.select{|k,v| k.to_s.match(/[a-z]/)}.each do |k,v|
    key = (k.to_s.ord - "a".ord).to_i
    hash[key] = v if hash[key] == nil
  end
  return coef
end

#get_degree(x) ⇒ Object



33
34
35
# File 'lib/epimath100/function.class.rb', line 33

def get_degree x
  return @coef[x]
end

#get_degree_maxObject



29
30
31
# File 'lib/epimath100/function.class.rb', line 29

def get_degree_max
  return @coef.rindex{|x| x != nil}
end