This file contains hidden or 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
source 'https://rubygems.org' | |
ruby '1.9.3' | |
gem 'airbrake' | |
gem 'bourbon' | |
gem 'delayed_job_active_record' | |
gem 'flutie' | |
gem 'high_voltage' | |
gem 'jquery-rails' |
This file contains hidden or 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
class Country < ActiveRecord::Base | |
has_many :cities, inverse_of: :country | |
end | |
class City < ActiveRecord::Base | |
belongs_to :country, inverse_of: :cities | |
end | |
country=Country.first | |
city=country.cities.first |
This file contains hidden or 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
module InWords | |
def in_words | |
numberString = "" | |
numToLettersHash = {0 => "", 1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five", 6 => "six", 7 => "seven", 8 => "eight", 9 => "nine", 10 => "ten", 11 => "eleven", 12 => "twelve", 13 => "thirteen", 14 => "fourteen", 15 => "fifteen", 16 => "sixteen", 17 => "seventeen", 18 => "eighteen", 19 => "nineteen", 20 => "twenty", 30 => "thirty", 40 => "forty", 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", 90 => "ninety",} | |
if self < 20 | |
return numberString = numToLettersHash[self] | |
elsif self < 100 | |
return numberString = numToLettersHash[self-(self%10)] + " " + numToLettersHash[self%10] | |
elsif (self%100) < 20 | |
return numberString = numToLettersHash[(self-(self%100))/100] + " hundred " + numToLettersHash[self%100] |
This file contains hidden or 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 'rspec' | |
module InWords | |
def in_words | |
#conditional statements | |
a = if self == 1_000_000_000_000 | |
"one trillion" | |
elsif self >= 1_000_000_000 #self is greater to or equal to 1 Billion | |
prefix = self / 1_000_000_000 |