Skip to content

Instantly share code, notes, and snippets.

class Numeric
def add(n)
self + n
end
def subtract(n)
self-n
end
def multiply_by(n)
module Calculator
def add(n)
self + n
end
def subtract(n)
self-n
end
def multiply_by(n)
module InWords
def in_words()
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
def greeter(first, last)
name = first + last
if %w{ ShereefBishay TonyPhillips AnneSpalding }.include? name
"I love Dev Bootcamp!"
elsif %w{ JesseFarmer RobertFletcher }.include? name
"Will you look at the C source code for this with me?"
else
"Well hello there."
end
end
def leap_year?(yr)
yr % 4 == 0 && ( yr % 100 != 0 || yr % 400 == 0 )
end
<h3>Numbers</h3>
<h4 class="gray">Addition, Subtraction, Multiplication</h4>
<h4 class="gray" >Division, Integers, And Floats</h4>
<h4 class="gray" >Variables</h4>
<h4 class="gray" >Arithmetic On Variables</h4>
<br />
<h3>Methods</h3>
<h4 class="gray" >Methods Definition</h4>
<h4 class="gray" >Arguments</h4>
<h4 class="gray" >Method Chaining</h4>
def one_more(ar)
ar << ar.last
end
def sum(ar)
ar.inject(0, :+)
end
def title_case(str)
str.split.map{ |el| el.capitalize }.join(" ")
end
def triangle(n1,n2,n3)
n1n2 = n1 == n2
n2n3 = n2 == n3
n1n3 = n1 == n3
if n1 >= n2 + n3 || n2 >= n1 + n3 || n3 >= n1 + n2
:invalid
elsif n1n2 && n2n3 && n1n3
:equilateral
elsif n1n2 || n2n3 || n1n3