Class: TfPointClass
- Inherits:
-
Object
- Object
- TfPointClass
- Includes:
- TfPoint::Calculate
- Defined in:
- lib/24point/base.rb
Constant Summary collapse
- NUMBER_TO_CAL =
24
Instance Attribute Summary collapse
-
#all_expression ⇒ Object
Returns the value of attribute all_expression.
-
#count_of_number ⇒ Object
Returns the value of attribute count_of_number.
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#given_numbers ⇒ Object
Returns the value of attribute given_numbers.
-
#number ⇒ Object
Returns the value of attribute number.
Instance Method Summary collapse
-
#initialize(*args) ⇒ TfPointClass
constructor
A new instance of TfPointClass.
- #result ⇒ Object
Methods included from TfPoint::Calculate
#devision_operation, #multi_operation, #plus_operation, #sub_operation
Constructor Details
#initialize(*args) ⇒ TfPointClass
Returns a new instance of TfPointClass.
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_expression ⇒ Object
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_number ⇒ Object
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 |
#expression ⇒ Object
Returns the value of attribute expression.
6 7 8 |
# File 'lib/24point/base.rb', line 6 def expression @expression end |
#given_numbers ⇒ Object
Returns the value of attribute given_numbers.
6 7 8 |
# File 'lib/24point/base.rb', line 6 def given_numbers @given_numbers end |
#number ⇒ Object
Returns the value of attribute number.
6 7 8 |
# File 'lib/24point/base.rb', line 6 def number @number end |
Instance Method Details
#result ⇒ Object
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 |