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 |
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
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 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 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
require 'jumpstart_auth' | |
class JSTwitter | |
attr_reader :client | |
def initialize | |
puts "Initializing" | |
@client = JumpstartAuth.twitter | |
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
require 'jumpstart_auth' | |
class JSTwitter | |
attr_reader :client | |
def initialize | |
puts "Initializing" | |
@client = JumpstartAuth.twitter | |
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 Sudoku | |
def initialize(puzzle) # puzzle == String | |
@puzzle = puzzle | |
@cell = Cell.new(puzzle) | |
@rows = Row.new(puzzle) | |
@column = Column.new(puzzle) | |
@three_by_three = ThreeByThree.new(puzzle) | |
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
require 'jumpstart_auth' | |
class JSTwitter | |
attr_reader :client | |
def initialize | |
puts "Initializing" | |
@client = JumpstartAuth.twitter | |
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 EightBall | |
def response | |
response_array = ["Signs point to yes", | |
"Signs point to no", | |
"AHAHAHAHA!", | |
"Outlook is positive", | |
"No way Jose!"] | |
response_num = rand(response_array.length) | |
puts response_output = response_array[response_num] |
OlderNewer