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 | |
num_digits = self.to_s.length | |
num_string = self.to_s | |
under_ten = { 0 => "zero", 1 => "one", 2 => "two", 3 => "three", | |
4 => "four", 5 => "five", 6 => "six", | |
7 => "seven", 8 => "eight", 9 => "nine" } | |
teens = { 10 => "ten", 11 => "eleven", 12 => "twelve", 13 => "thirteen", | |
14 => "fourteen", 15 => "fifteen", 16 => "sixteen", |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<script type="text/javascript"> | |
var message = { | |
user: "bob", | |
text: "aldfkja" | |
}; |
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
def translate(word) | |
start_point = vowels_start(word) | |
end_point = word.length - 1 | |
if start_point == 0 | |
word + "ay" | |
else | |
word[start_point, end_point] + word[0, start_point] + "ay" | |
end | |
end |
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 Fixnum | |
def in_words | |
ten = 10 | |
hundred = 100 | |
thousand = 1_000 | |
million = 1_000_000 | |
billion = 1_000_000_000 | |
trillion = 1_000_000_000_000 |
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 Dictionary | |
def initialize | |
@my_hash = {} | |
end | |
def add(word_hash) | |
if word_hash.is_a?Hash | |
@my_hash.merge!(word_hash) | |
else | |
@my_hash[word_hash] = nil |
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 Book | |
attr_accessor :title | |
def initialize | |
@title = "" | |
end | |
def title=(name) | |
arr = name.split | |
no_caps = ["the", "an", "a", "and", "in"] |
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 RPNCalculator | |
def initialize | |
@rpn = [] | |
end | |
def push(num) | |
@rpn << num | |
end |
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 Array | |
def new_count | |
count = 0 | |
(1..self.length).each do |i| | |
count += 1 if yield(self[i-1]) | |
end | |
count | |
end | |
end |
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 'rubygems' | |
require 'oauth' | |
require 'twitter' | |
consumer_key = 'HIDDEN' | |
consumer_secret = 'HIDDEN' | |
@consumer = OAuth::Consumer.new( | |
consumer_key, | |
consumer_secret, |
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
# Create a Red Sox class that represents the starting line-up of the Red Sox in a recent game. The line-up at the start of the game, 1 through 9, is given below with the pitcher indicated at 0 as he doesn't bat (sorry, NL fans): | |
# | |
# * 1, Aviles, SS | |
# * 2, Pedroia, 2B | |
# * 3, Youkilis, 1B | |
# * 4, Ortiz, DH | |
# * 5, Middlebrooks, 3B | |
# * 6, Gonzalez, OF | |
# * 7, Saltalamacchia, C | |
# * 8, McDonald, OF |
OlderNewer