Skip to content

Instantly share code, notes, and snippets.

@bzerangue
Created December 6, 2011 18:26
Show Gist options
  • Save bzerangue/1439296 to your computer and use it in GitHub Desktop.
Save bzerangue/1439296 to your computer and use it in GitHub Desktop.
Convert Number to Word - Sass Function
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'
##
@sonnyprince
Copy link

Just a note, You may need to use: require_relative in the config.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment