Class: Obfuscator::Summation

Inherits:
BinaryExpression show all
Defined in:
lib/number_obfuscator/summation.rb

Instance Attribute Summary

Attributes inherited from BinaryExpression

#left, #right

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BinaryExpression

#initialize, make

Methods inherited from Expression

addType, make, makeExpression

Constructor Details

This class inherits a constructor from Obfuscator::BinaryExpression

Class Method Details

.canDo(n) ⇒ Object


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

def Summation.canDo(n)
  n > 2
end

.makePair(n) ⇒ Object


20
21
22
23
24
# File 'lib/number_obfuscator/summation.rb', line 20

def Summation.makePair(n)
  l = rand(n - 1) + 1
  r = n - l
  [l, r]
end

Instance Method Details

#to_sObject


8
9
10
# File 'lib/number_obfuscator/summation.rb', line 8

def to_s
  "#{left.to_s}+#{right.to_s}"
end

#to_texObject


12
13
14
# File 'lib/number_obfuscator/summation.rb', line 12

def to_tex
  "#{left.to_tex}+#{right.to_tex}"
end