Class: Jekyll::TallyTags::Methods

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-tally-tags/methods.rb

Class Method Summary collapse

Class Method Details

.div(a, b) ⇒ Object

Parameters:

  • a (Integer)
  • b (Integer)


17
18
19
# File 'lib/jekyll-tally-tags/methods.rb', line 17

def self.div(a, b)
  self.to_f_s(a.to_f / b.to_f)
end

.mul(a, b) ⇒ Object

Parameters:

  • a (Integer)
  • b (Integer)


23
24
25
# File 'lib/jekyll-tally-tags/methods.rb', line 23

def self.mul(a, b)
  self.to_f_s(a.to_f * b.to_f)
end

.sub(a, b) ⇒ Object

Parameters:

  • a (Integer)
  • b (Integer)


29
30
31
# File 'lib/jekyll-tally-tags/methods.rb', line 29

def self.sub(a, b)
  self.to_f_s(a.to_f - b.to_f)
end

.sum(a, b) ⇒ Object

Parameters:

  • a (Integer)
  • b (Integer)


11
12
13
# File 'lib/jekyll-tally-tags/methods.rb', line 11

def self.sum(a, b)
  self.to_f_s(a.to_f + b.to_f)
end

.to_f_s(number) ⇒ Object

Parameters:

  • number (Float)


34
35
36
37
38
39
40
# File 'lib/jekyll-tally-tags/methods.rb', line 34

def self.to_f_s(number)
  if number - number.round != 0
    number.round(2).to_s
  else
    number.round.to_s
  end
end