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
#!/usr/bin/env ruby | |
# O(nlogn) solution for the problem from the Coding Dojo at RailsCamp UK 2009 | |
# Author: Bartosz Blimke | |
#Binary search in an array. I was too lazy so I adopted code from http://0xcc.net/ruby-bsearch/ | |
class Array | |
def bsearch_upper_boundary (range = 0 ... self.length, &block) | |
lower = range.first() -1 |
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 Person | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
end | |
person = Person.new("Trygve Reenskaug") |
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 Vehicle | |
attr_reader: speed | |
end | |
class Ship < Vehicle | |
attr_accessor: anchor | |
end | |
class Airplane < Vehicle | |
attr_accessor :wings |
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 FootballPlayer < Person | |
def kick_ball(ball) | |
# kicking ball logic | |
end | |
def run | |
# running logic | |
end | |
end |