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 times_table(n) | |
(1..n).each do |row_num| | |
line = "" | |
(1..n).each{ |col_num| line += "#{row_num * col_num}\t"} | |
puts line | |
end | |
end | |
times_table(5) |
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
# Slightly better name, bang (!) to indicate side effects | |
def process_raw_data! | |
# See: | |
# http://po-ru.com/diary/rubys-magic-underscore/ | |
# http://po-ru.com/diary/destructuring-assignment-in-ruby/ | |
self.raw_data.each do |date, name, url, cb_url, funding_type, value| | |
Company.where(name: name).first_or_create(url: url, cb_url: cb_url) | |
# See: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#method-c-strptime | |
Event.where(funding_type: funding_type, date: Date.strptime(date, '%M/%y'), value: value).first_or_create |
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 GuessingGame | |
def initialize(answer) | |
@answer = answer | |
end | |
def guess(g) | |
if @answer < g | |
return :high |
NewerOlder