Skip to content

Instantly share code, notes, and snippets.

View fenixbrassi's full-sized avatar

Ernesto Ponce fenixbrassi

View GitHub Profile
@fenixbrassi
fenixbrassi / gist:8015638
Created December 18, 2013 01:02
Enumerable functions
irb(main):054:0> [].any?
=> false
irb(main):055:0> [2].any?
=> true
irb(main):058:0> [2,2,3,4,5,6,7].count
=> 7
irb(main):061:0> [2,2,3,4,5,6,7].drop(1)
=> [2, 3, 4, 5, 6, 7]
@fenixbrassi
fenixbrassi / gist:8015793
Created December 18, 2013 01:19
Array Example of usage
#Write a program that asks user to type as many words as he/she wants.
#One word per line, continuing until the user presses enter on an empty line. The output of the program should be the words in alphabetical order.
def order_string(paragraph)
end
puts " Tell me a story "
story = ""
@fenixbrassi
fenixbrassi / gist:8033454
Created December 19, 2013 02:33
Hash Practice
#hash
student = {}
student["First Name"] = “John”
student["Last Name"] = “Doe”
student["Age"] = 15
student["Subjects"] = {}
student["Subjects"][“Physics”] = 75
student["Subjects"][”Chemistry”] = 98
student["Subjects"][”Maths”] = 85
@fenixbrassi
fenixbrassi / gist:8033869
Last active December 31, 2015 19:29
String practice
#strings practice
def longest_strings( param , n )
param.split(' ').sort_by(&:length).reverse.first(3)
end
puts "Give me the string"
words = gets.chomp
@fenixbrassi
fenixbrassi / gist:8108403
Created December 24, 2013 03:26
Practicing with classes methods
class Employee
attr_accessor :first_name, :last_name, :salary, :age, :months_of_service
def initialize(first_name , last_name, salary, age, months_of_service)
@first_name = first_name
@last_name = last_name
@salary = salary
@age = age
@months_of_service = months_of_service
end