Returns the sum of two numbers.
4.add(2) #=> 6Returns if a number is within the degree of another.
10.006.close?(10, 0.1) #=> trueReturns the n decremented number.
1.decrement #=> 0
1.decrement(0.5) #=> 0.5Returns the absolute difference between numbers.
5.delta(3) #=> 2
3.delta(5) #=> 2Returns a string representation of the number.
5.delimit #=> "1,000,000.1234"
3.delimit(delimiter: '.', separator: ',') #=> "1.000.000,1234"Returns the difference between numbers.
5.distance(3) #=> 2
3.distance(5) #=> -2Returns the division of two numbers.
4.divide(2) #=> 2
0.divide(2) #=> 0
4.divide(0) #=> 0Returns if matching equality using ==.
3.equal_to?(2) #=> false
3.equal_to?(3) #=> trueReturns the numbers after '.' of a float.
1.0.fraction #=> 0.0
12.2456.fraction #=> 0.2456
-12.2456.fraction #=> 0.2456Returns if its a fraction.
1.0.fraction? #=> false
12.2456.fraction? #=> trueReturns if self is greater than n.
3.greater_than?(2) #=> true
3.greater_than?(3) #=> false
3.greater_than?(4) #=> falseReturns if self is greater than or equal to n.
3.greater_than_or_equal_to?(2) #=> true
3.greater_than_or_equal_to?(3) #=> true
3.greater_than_or_equal_to?(4) #=> falseReturns the n incremented number.
1.increment #=> 2
1.increment(0.5) #=> 1.5Returns if n is greater than start and less than finish. Similar to between but does not return true if equal to self.
3.inside?(1, 5) #=> true
3.inside?(3, 5) #=> falseReturns if self is less than n.
3.less_than?(2) #=> false
3.less_than?(3) #=> false
3.less_than?(4) #=> trueReturns if self is less than or equal to n.
3.less_than_or_equal_to?(2) #=> false
3.less_than_or_equal_to?(3) #=> true
3.less_than_or_equal_to?(4) #=> trueReturns if a number is greater than one.
4.many? #=> true
1.many? #=> falseReturns the difference of a number and a percentage of it.
4.markdown_percentage(25) #=> 3Returns the sum of a number and a percentage of it.
4.markup_percentage(25) #=> 5Returns the multiplication of two numbers.
4.multiply(2) #=> 8Returns if a number can be evenly divided by n.
9.multiple_of?(3) #=> true
7.multiple_of?(3) #=> falseReturns the negation of a number.
4.negate #=> -4
-2.negate #=> 2Returns if a number is to zero.
0.none? #=> true
1.none? #=> falseReturns if not matching equality using !=.
3.not_equal_to?(2) #=> true
3.not_equal_to?(3) #=> falseReturns if a number is equal to one.
1.one? #=> true
1.0.one? #=> true
4.one? #=> falseReturns the suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
'1'.ordinal #=> 'th'
'2'.ordinal #=> 'nd'
'3'.ordinal #=> 'rd'
'11'.ordinal #=> 'th'transforms a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
'1'.ordinalize #=> '1th'
'2'.ordinalize #=> '2nd'
'3'.ordinalize #=> '3rd'
'11'.ordinalize #=> '4th'Returns if n is less than start or greater than finish.
3.outside?(4, 5) #=> true
3.outside?(3, 5) #=> falseReturns a string representation of the number padded with pad_num to a specified length.
3.pad #=> '003'
3.pad(pad_number: 1) #=> '113'
3.pad(precision: 4) #=> '0003'Returns a string of padded after the '.' to n amount.
| Option | Type | Default |
|---|---|---|
| pad_number | integer | 0 |
| precision | integer | 2 |
| separator | string | '...' |
3.pad_precision #=> '3.00'
3.5.pad_precision #=> '3.50'
3.pad_precision(pad_number: 1) #=> '3.11'Returns the percentage of a number in relation to another number.
0.percentage_of(4) #=> 0
2.percentage_of(0) #=> 0
2.percentage_of(4) #=> 50.0Returns the nth power of a number.
4.power(2) #=> 16Returns a range from the number plus-or-minus a given value.
4.range(2) #=> 2..6Returns the nth root of a number.
4.root(2) #=> 2Returns a number rounded down to given value.
2.128.round_down #=> 2.0
2.128.round_down(2) #=> 2.12
2.round_down(2) #=> 2.0Returns the difference of two numbers.
4.subtract(2) #=> 2Converts a number to currency string.
| Option | Type | Default |
|---|---|---|
| precision | integer | 2 |
| unit | string | '$' |
3.to_currency #=> '$3.00'
3.1.to_currency #=> '$3.10'
3.11.to_currency #=> '$3.11'
3.11111.to_currency #=> '$3.11'
3.to_currency(unit: '@') #=> '@3.00'Returns the value in values that is nearest to the number.
5.to_nearest_value([1, 3, 6, 9]) #=> 6
3.5.to_nearest_value([3.0, 3.3, 3.6, 3.9]) #=> 3.6Returns a range of a number from negative to positive.
5.to_range #=> -5..5
-5.to_range #=> -5..5Converts a number to percentage string.
| Option | Type | Default |
|---|---|---|
| precision | integer | 2 |
| unit | string | '%' |
3.to_percentage #=> '3.00%'
3.1.to_percentage #=> '3.10%'
3.11.to_percentage #=> '3.11%'
3.11111.to_percentage #=> '3.11%'
3.to_percentage(unit: '@') #=> '3.00@'Returns if another number is approximately equal within a given epsilon
10.006.within?(10, 0.1) #=> true