 // MARK: - Equatable
 
 extension Unit: Equatable {
+    
+    /**
+     Compares instance to a conforming type.
+     
+     - parameter other: given `unit` to compare
+     - returns:
+     */
     public func equals(other: Unit) -> Bool {
         if other.dynamicType !== self.dynamicType {
             return false


// MARK: - UnitConvertible

public protocol UnitConvertible {
    func convert(amount: NSNumber, to: Unit) -> NSNumber
    func convert(amount: NSNumber, from: Unit) -> NSNumber
    func convert(amount: NSNumber, from: Unit, to: Unit) -> NSNumber
    func isConvertible(with: Unit) -> Bool
}

extension Unit: UnitConvertible {

    public func convert(amount: NSNumber, to: Unit) -> NSNumber {
        return self.convert(amount, from: self, to: to)
    }

    public func convert(amount: NSNumber, from: Unit) -> NSNumber {
        return self.convert(amount, from: from, to: self)
    }

    public func convert(amount: NSNumber, from: Unit, to: Unit) -> NSNumber {
        let baseAmount = from.convertToBaseUnit(amount)
        let converted = to.convertFromBaseUnit(baseAmount)
        return converted
    }

    public func isConvertible(with: Unit) -> Bool {
        return with.dynamicType == self.dynamicType
    }


import Foundation

/**
 Represents an `unit of measurement`.
 */
public class Unit {
    public let name: String
    public let symbol: String
    public let ratio: NSDecimalNumber

    /**
     Instantiates an `unit` object.
     
     - parameter name: unit name.
     - parameter symbol: unit symbol.
     - parameter ratio: conversion ratio to a base unit.
     */
    public init(name: String, symbol: String, ratio: NSNumber) {
        self.name = name
        self.symbol = symbol
        self.ratio = NSDecimalNumber(decimal: ratio.decimalValue)
    }

    /**
     Converts given amount from a `base unit` to the `current unit`.
     
     - parameter amount: `amount` in a `base unit`.
     
     - returns: `amount` converted to the `current unit`.
     */
    public func convertFromBaseUnit(amount: NSNumber) -> NSNumber {
        let converted = NSDecimalNumber(decimal: amount.decimalValue)
        return converted.decimalNumberByDividingBy(self.ratio)
    }

    /**
     Converts given amount from the current unit to a base unit.
     
     - parameter amount: `amount` in the `current unit`.
     
     - returns: `amount` converted to a `base unit`.
     */
    public func convertToBaseUnit(amount: NSNumber) -> NSNumber {
        let converted = NSDecimalNumber(decimal: amount.decimalValue)
        return converted.decimalNumberByMultiplyingBy(self.ratio)
