Class: Sangaku::Star

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/sangaku/star.rb

Instance Method Summary collapse

Constructor Details

#initialize(center, size) ⇒ Star

Returns a new instance of Star.



7
8
9
# File 'lib/sangaku/star.rb', line 7

def initialize(center, size)
  @center, @size = Point.new(*center), Point.new(*size)
end

Instance Method Details

#<=>(other) ⇒ Object



19
20
21
# File 'lib/sangaku/star.rb', line 19

def <=>(other)
  other.fitness <=> fitness
end

#centerObject



11
12
13
# File 'lib/sangaku/star.rb', line 11

def center
  @center
end

#fitnessObject



15
16
17
# File 'lib/sangaku/star.rb', line 15

def fitness
  @fitness ||= (@size.w * @size.h)/(1+0.1*(@size.w-@size.h).abs)
end