Class: TfPointClass

Inherits:
Object
  • Object
show all
Includes:
TfPoint::Calculate
Defined in:
lib/24point/base.rb

Constant Summary collapse

NUMBER_TO_CAL =
24

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TfPoint::Calculate

#devision_operation, #multi_operation, #plus_operation, #sub_operation

Constructor Details

#initialize(*args) ⇒ TfPointClass

Returns a new instance of TfPointClass.

Raises:



11
12
13
14
15
16
17
# File 'lib/24point/base.rb', line 11

def initialize(*args)
  args.flatten!
  raise TfPoint::Exception.new("Sorry, Given arguments should be numbers.") if args.any?{|arg| !arg.is_a? Fixnum }
  @count_of_number = args.length
  @given_numbers = args
  @all_expression = []
end

Instance Attribute Details

#all_expressionObject

Returns the value of attribute all_expression.



6
7
8
# File 'lib/24point/base.rb', line 6

def all_expression
  @all_expression
end

#count_of_numberObject

Returns the value of attribute count_of_number.



6
7
8
# File 'lib/24point/base.rb', line 6

def count_of_number
  @count_of_number
end

#expressionObject

Returns the value of attribute expression.



6
7
8
# File 'lib/24point/base.rb', line 6

def expression
  @expression
end

#given_numbersObject

Returns the value of attribute given_numbers.



6
7
8
# File 'lib/24point/base.rb', line 6

def given_numbers
  @given_numbers
end

#numberObject

Returns the value of attribute number.



6
7
8
# File 'lib/24point/base.rb', line 6

def number
  @number
end

Instance Method Details

#resultObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/24point/base.rb', line 19

def result
  return all_expression if all_expression != []
  given_numbers.permutation.to_a.uniq.each do |given_number|
    @number = given_number
    @expression = given_number.collect{|number| number.to_s}
    calculate(count_of_number)
  end
  all_expression.uniq!
  return all_expression
end