This file contains 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 | |
# Project 3.7 | |
class FibSequence | |
include Enumerable | |
def initialize(n) | |
@max = n | |
@x = 0 | |
@y = 1 |
This file contains 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 | |
# Project 3.7 | |
module Enumerable | |
def each_with_custom_index (start, step) | |
index = start | |
self.each do |x| | |
yield x, index | |
index+= step |
This file contains 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 | |
# Project 3.2 | |
# Print an objects class and it's ancestors up to BasicObject | |
def class_print(o) | |
c = o.class | |
until c.nil? do | |
puts c | |
c = c.superclass | |
end |
This file contains 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 | |
# Project 3.5 | |
class Time | |
def at_beginning_of_year | |
self.class.local self.year | |
end | |
end | |
class Fixnum |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<layout> | |
<!-- ############# GLOBAL LAYOUT UPDATES ############# --> | |
<default> | |
<!-- Remove unwanted blocks entirely | |
<remove name="right.poll"/> | |
<remove name="right.permanent.callout"/> |
This file contains 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 daughter extends parent implements teenager { | |
public $attitude; | |
private $moods = array('happy', 'angry', 'sulky', 'upset', 'silly', 'grumpy'); | |
public function __construct() { | |
$this->attitude = $this->moods[array_rand($moods)]; | |
$this->wakeup(time()); | |
} |
NewerOlder