Module: MyCal

Defined in:
lib/myCal.rb,
lib/myCal/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.add(n1, n2) ⇒ Object

define add function



11
12
13
# File 'lib/myCal.rb', line 11

def self.add(n1, n2)
  return n1+n2  # return result of addition
end

.div(n1, n2) ⇒ Object

define div function



26
27
28
29
30
31
32
33
34
35
# File 'lib/myCal.rb', line 26

def self.div(n1, n2)
  n1 = n1.to_f # convert number to flaot
  n2 = n2.to_f  # convert number to flaot
  if n2 == 0  ## check n2 is equal to zero or not
    return "Divisor can't be zero!"
  else
    return (n1/n2)# return result of division
  end  ## end of if

end

.mtp(n1, n2) ⇒ Object

define mtp function



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

def self.mtp(n1, n2)
  return n1*n2    # return result of multiplication
end

.sub(n1, n2) ⇒ Object

define sub function



16
17
18
# File 'lib/myCal.rb', line 16

def self.sub(n1, n2)
  return n1-n2 # return result of suntraction
end