class EliteUniverse::Galaxy
Public Class Methods
new(a, b, c)
click to toggle source
# File lib/elite_universe/galaxy.rb, line 7 def initialize a, b, c @initial_planet = Planet.new(a, b, c) end
Public Instance Methods
[](*args)
click to toggle source
# File lib/elite_universe/galaxy.rb, line 24 def [] *args 255.times .lazy .inject([@initial_planet]) { |ps| ps + [ps[-1].next] }[*args] end
each(&block)
click to toggle source
# File lib/elite_universe/galaxy.rb, line 11 def each &block 256.times.inject(@initial_planet) do |p| block.call(p) p.next end end
planets()
click to toggle source
# File lib/elite_universe/galaxy.rb, line 18 def planets puts "DEPRECATED" puts "In place of `galaxy.planets[n]` use `galaxy[n]`" self.map { |p| p } end