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 ArrayIterator | |
def initialize(array) | |
@array = array | |
@index = 0 | |
end | |
def has_next? | |
@index < @array.length | |
end |
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 Command | |
attr_reader :description | |
def initialize(description) | |
@description = description | |
end | |
def execute | |
end |
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 AccountProxy | |
def initialize(real_account) | |
@subject = real_account | |
end | |
def method_missing(name, *args) | |
puts "Delegating #{name} message to subject." | |
@subject.send(name, *args) | |
end | |
end |
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 SimpleWriter | |
def initialize(path) | |
@file = File.open(path,'w') | |
end | |
def write_line(line) | |
@file.print(line) | |
@file.print("\n") | |
end |
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 SimpleLogger | |
attr_reader :level | |
ERROR = 1 | |
WARNING = 2 | |
INFO = 3 | |
def initialize | |
@log = File.open("log.txt", "w") | |
@level = WARNING |
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
# coding: utf-8 | |
class Algae | |
def initialize(name) | |
@name = name | |
end | |
def grow | |
puts "藻 #{@name} は日光浴を浴びて育っています" | |
end |
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
# coding: utf-8 | |
class Algae | |
def initialize(name) | |
@name = name | |
end | |
def grow | |
puts "藻 #{@name} は日光浴を浴びて育っています" | |
end |
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 CPU | |
end | |
class TurboCPU < CPU | |
end | |
class BasicCPU < CPU | |
end | |
class Drive |
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
test |
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 | |
# coding: utf-8 | |
total = 500 | |
coins = [1, 5, 10, 50, 100, 500] | |
size = total/coins.min | |
ret = 1.upto(size).inject([]) do |r, n| | |
comb = coins.repeated_combination(n) | |
r + comb.select do |c| | |
c.inject(:+).eql?(total) |