fraction.module in Fraction 7
Same filename and directory in other branches
Fraction
File
fraction.moduleView source
<?php
/**
* @file
* Fraction
*/
/***************************************************************
* Includes
* *************************************************************/
// Include the Fraction Field API functions.
require_once __DIR__ . '/fraction.field.inc';
// Include the Fraction Feeds integration code.
require_once __DIR__ . '/fraction.feeds.inc';
/***************************************************************
* Constants
* *************************************************************/
// Default decimal precision.
define('FRACTION_PRECISION_DEFAULT', 0);
/***************************************************************
* Utility functions
* *************************************************************/
/**
* Fraction factory function.
*
* @param $numerator
* The fraction's numerator.
* @param $denominator
* The fraction's denominator.
*
* @return \Fraction
* Returns a new fraction object.
*/
function fraction($numerator = 0, $denominator = 1) {
return new Fraction($numerator, $denominator);
}
/**
* Convert a decimal value into a fraction object.
*
* @param $value
* The decimal value to be converted.
*
* @return \Fraction
* Returns a new fraction object.
*/
function fraction_from_decimal($value) {
return fraction()
->fromDecimal($value);
}
/***************************************************************
* Views API hooks
* *************************************************************/
/**
* Implements hook_views_api().
*/
function fraction_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'fraction') . '/views',
);
}
Functions
Name | Description |
---|---|
fraction | Fraction factory function. |
fraction_from_decimal | Convert a decimal value into a fraction object. |
fraction_views_api | Implements hook_views_api(). |
Constants
Name | Description |
---|---|
FRACTION_PRECISION_DEFAULT |