Class: Lexrb
- Inherits:
-
Object
- Object
- Lexrb
- Defined in:
- lib/lexrb.rb
Instance Attribute Summary collapse
-
#sum ⇒ Object
Returns the value of attribute sum.
-
#word ⇒ Object
Returns the value of attribute word.
Instance Method Summary collapse
- #calculate ⇒ Object
- #get_array ⇒ Object
-
#initialize ⇒ Lexrb
constructor
A new instance of Lexrb.
Constructor Details
#initialize ⇒ Lexrb
Returns a new instance of Lexrb.
25 26 27 |
# File 'lib/lexrb.rb', line 25 def initialize @sum = 0 end |
Instance Attribute Details
#sum ⇒ Object
Returns the value of attribute sum.
23 24 25 |
# File 'lib/lexrb.rb', line 23 def sum @sum end |
#word ⇒ Object
Returns the value of attribute word.
23 24 25 |
# File 'lib/lexrb.rb', line 23 def word @word end |
Instance Method Details
#calculate ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/lexrb.rb', line 33 def calculate get_array @letter_array.each do |letter| @num = case letter when "Α", "α", "ά" then 1 when "Β", "β" then 2 when "Γ", "γ" then 3 when "Δ", "δ" then 4 when "Ε", "ε", "έ" then 5 when "ς" then 6 when "Ζ", "ζ" then 7 when "Η", "η", "ή" then 8 when "Θ", "θ" then 9 when "Ι", "ι", "ί" then 10 when "Κ", "κ" then 20 when "Λ", "λ" then 30 when "Μ", "μ" then 40 when "Ν", "ν" then 50 when "Ξ", "ξ" then 60 when "Ο", "ο", "ό" then 70 when "Π", "π" then 80 when "Ρ", "ρ" then 100 when "Σ", "σ" then 200 when "Τ", "τ" then 300 when "Υ", "υ", "ύ" then 400 when "Φ", "φ" then 500 when "Χ", "χ" then 600 when "Ψ", "ψ" then 700 when "Ω", "ω", "ώ" then 800 else 0 end @sum += @num end @sum end |
#get_array ⇒ Object
29 30 31 |
# File 'lib/lexrb.rb', line 29 def get_array @letter_array = @word.split(//) end |