Skip to content

Instantly share code, notes, and snippets.

class ArrayIterator
def initialize(array)
@array = array
@index = 0
end
def has_next?
@index < @array.length
end
class Command
attr_reader :description
def initialize(description)
@description = description
end
def execute
end
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
class SimpleWriter
def initialize(path)
@file = File.open(path,'w')
end
def write_line(line)
@file.print(line)
@file.print("\n")
end
class SimpleLogger
attr_reader :level
ERROR = 1
WARNING = 2
INFO = 3
def initialize
@log = File.open("log.txt", "w")
@level = WARNING
# coding: utf-8
class Algae
def initialize(name)
@name = name
end
def grow
puts "藻 #{@name} は日光浴を浴びて育っています"
end
# coding: utf-8
class Algae
def initialize(name)
@name = name
end
def grow
puts "藻 #{@name} は日光浴を浴びて育っています"
end
class CPU
end
class TurboCPU < CPU
end
class BasicCPU < CPU
end
class Drive
#!/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)