Created
December 6, 2011 18:26
-
-
Save bzerangue/1439296 to your computer and use it in GitHub Desktop.
Convert Number to Word - Sass Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sass' | |
## install Linguistics gem, sudo install gem linguistics | |
require 'linguistics' | |
Linguistics::use( :en ) # extends Array, String, and Numeric | |
## this is the linguistics gem, | |
## instructions on how to use, http://deveiate.org/projects/Linguistics/wiki/English | |
## 5.en.numwords would output 'five' | |
## Sass Function | |
module Sass::Script::Functions | |
def convert_number_to_word(number) | |
assert_type number, :Number | |
Sass::Script::String.new(number.value.en.numwords) | |
end | |
declare :convert_number_to_word, :args => [:Number] | |
end | |
## To use in Compass, save this file in the same directory as the config.rb | |
## and add as a required library in your config.rb file. | |
## | |
## require 'convert-number-to-word' | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a note, You may need to use: require_relative in the config.rb