Created
February 5, 2012 23:06
-
-
Save spllr/1748327 to your computer and use it in GitHub Desktop.
Calculate your number according to Numerology
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
| # | |
| # Calculate your number according to http://www.astrology.com/what-numerology/2-d-d-66854 | |
| # | |
| # | |
| # HOW ARE NUMEROLOGY CALCULATIONS DONE | |
| # In numerology, all numbers are reduced to the single digits 1 through 9 except the special master numbers 11 and 22. 1, 2, 3, 4, 5, 6, 7, 8, 9, 11 and 22 represent the major vibration rates associated with people’s characteristics. | |
| # The numbers are reduced by simple addition. The number 15, for instance, is reduced by adding 1 + 5 to get 6. Similarly, the number 1974 can be reduced by adding 1 + 9 + 7 + 4 to get 21. The 21 can be further reduced by adding 2 + 1 to get 3. | |
| # Letters in individuals’ names are converted to numbers and then added together. These numbers, in turn, are also reduced. The letter A, for instance, is 1; the letter B is 2; the letter C is 3, and so forth. The following table shows the numbers assigned to all 26 letters in the English alphabet. | |
| # | |
| # 1 2 3 4 5 6 7 8 9 | |
| # A B C D E F G H I | |
| # J K L M N O P Q R | |
| # S T U V W X Y Z | |
| # | |
| # NOTE: | |
| # You will need the sinatra and haml gem | |
| # %> gem install haml sinatra | |
| # | |
| # USAGE: | |
| # ruby numerology.rb | |
| # | |
| ENV['RACK_ENV'] ||= 'production' | |
| require "sinatra" | |
| require "haml" | |
| helpers do | |
| # Reduces the number to 1 to 9 or 22 or 11 | |
| # | |
| def reduce_number(number) | |
| until number == 22 || number == 11 || number <= 9 | |
| number = number.to_s.split("").map(&:to_i).inject(:+) | |
| end | |
| number | |
| end | |
| # The returns the value of the word | |
| # | |
| def value_for_word(word) | |
| letters = word.upcase.split("").reject{ |v| v == " "} | |
| letters.map { |l| number_for_letter(l) }.inject(:+) | |
| end | |
| # Returns the corresponding number for letter | |
| # | |
| def number_for_letter(letter) | |
| letter_value_table[letter] | |
| end | |
| # Based on table | |
| # | |
| # 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
| # A | B | C | D | E | F | G | H | I | |
| # J | K | L | M | N | O | P | Q | R | |
| # S | T | U | V | W | X | Y | Z | |
| # | |
| def letter_value_table | |
| return @table if @table | |
| @table = {} | |
| ('A'..'Z').to_a.each_with_index do |l,i| | |
| @table[l] = i%9 + 1 | |
| end | |
| return @table | |
| end | |
| end | |
| get '/' do | |
| haml :index | |
| end | |
| post '/calculate' do | |
| @name = params[:name] | |
| @word_value = value_for_word(@name) | |
| @reduced_value = reduce_number(@word_value) | |
| haml :calculate | |
| end | |
| __END__ | |
| @@index | |
| %h1 | |
| Numerology | |
| %form{ :action => "/calculate", :method => :post } | |
| %label{ :for => :name } | |
| Your Name | |
| %input{ :type => :text, :name => :name, :id => :name } | |
| %button{ :type => :submit } | |
| Calculate Number | |
| @@calculate | |
| =haml :index, :layout => false | |
| .result | |
| Your the number for #{@name} is #{@word_value} | |
| .result | |
| That gives us the number #{@reduced_value} | |
| @@layout | |
| !!! | |
| %html | |
| %head | |
| %title | |
| Numerology - Calculate Your Number | |
| %body | |
| #page | |
| =yield |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a great implementation of a Sinatra-based numerology app! I really like how you handled the reduction logic in the
reduce_numberhelper—the use ofuntilloops to preserve Master Numbers 11 and 22 is a clean and efficient way to handle those specific vibrations. The way you mapped the alphabet to the 1-9 table using the index mod 9 (i%9 + 1) is a clever bit of coding that keeps theletter_value_tablelogic very concise.I’ve been working on a similar project, exploring how to scale these kinds of calculations for larger datasets. While building an interactive Name Numerology Calculator, I found that moving from a static table to a more dynamic UI helps users engage more with the 'Planes of Expression' beyond just the basic reduction. It’s cool to see a Ruby/Haml version of this; it really highlights the versatility of numerology as a logic-based system. Keep up the great work on this [repo! https://namenumerologycal.com/