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
class Hero | |
def initialize(level) | |
@level = level | |
@health = @level * 100 | |
end | |
def life | |
@health | |
end |
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
class Book | |
attr_reader :title | |
def title=(title) | |
@title = title.split | |
@title.each do |word| | |
a = ["the", "in", "a", "an", "and"] | |
if a.include?(word.downcase) | |
word.downcase! | |
else |
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
class Array | |
def new_count | |
final = 0 | |
(1..self.length-1)each do |i| | |
final += 1 if yield(self[i]) | |
end | |
return final | |
end | |
end |
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
class Dictionary | |
attr_reader :entries | |
def initialize() | |
@entries = {} | |
end | |
def add(words) | |
if words.class == String | |
@entries.merge!({words => nil}) | |
else |
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
module InWords | |
def magic | |
ones_array = %w{ not_called one two three four five six seven eight nine ten} | |
tens_array = %w{ not_called not_called twenty thirty forty fifty sixty seventy eighty ninety} | |
teens_array = [ "" ] + %w{ one two three four five six seven eight nine ten eleven twelve | |
thirteen fourteen fifteen sixteen seventeen eighteen nineteen} | |
# if self == 0 | |
# return "zero" | |
# end |
NewerOlder