You are here

fraction.module in Fraction 7

Same filename and directory in other branches
  1. 8 fraction.module
  2. 2.x fraction.module

Fraction

File

fraction.module
View 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

Namesort descending Description
fraction Fraction factory function.
fraction_from_decimal Convert a decimal value into a fraction object.
fraction_views_api Implements hook_views_api().

Constants