Skip to content

Instantly share code, notes, and snippets.

@eniolopes
Created May 7, 2011 07:34
Show Gist options
  • Save eniolopes/960286 to your computer and use it in GitHub Desktop.
Save eniolopes/960286 to your computer and use it in GitHub Desktop.
class PotenciaDeQuatro
attr_reader :valor
def initialize(valor)
@valor = valor
end
def succ
PotenciaDeQuatro.new(@valor*4)
end
def <=>(potencia)
@valor <=> potencia.valor
end
def to_s
@valor.to_s
end
end
potencia1 = PotenciaDeQuatro.new(4)
potencia2 = PotenciaDeQuatro.new(64)
(potencia1..potencia2).each do |potencia|
puts potencia
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment