Class: ArtDecomp::Arch

Inherits:
Object
  • Object
show all
Defined in:
lib/art-decomp/arch.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pins, pons) ⇒ Arch

Returns a new instance of Arch.



9
10
11
# File 'lib/art-decomp/arch.rb', line 9

def initialize pins, pons
  @pins, @pons = pins, pons
end

Instance Attribute Details

#pinsObject (readonly)

Returns the value of attribute pins.



3
4
5
# File 'lib/art-decomp/arch.rb', line 3

def pins
  @pins
end

#ponsObject (readonly)

Returns the value of attribute pons.



3
4
5
# File 'lib/art-decomp/arch.rb', line 3

def pons
  @pons
end

Class Method Details

.[](pins, pons) ⇒ Object



5
6
7
# File 'lib/art-decomp/arch.rb', line 5

def self.[] pins, pons
  new pins, pons
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



13
14
15
# File 'lib/art-decomp/arch.rb', line 13

def == other
  [@pins, @pons] == [other.pins, other.pons]
end

#cells(archs) ⇒ Object



17
18
19
20
# File 'lib/art-decomp/arch.rb', line 17

def cells archs
  pons = archs.select { |a| a.pins >= @pins }.map(&:pons).max
  (@pons % pons).zero? ? @pons / pons : @pons / pons + 1 rescue nil
end

#hashObject



24
25
26
# File 'lib/art-decomp/arch.rb', line 24

def hash
  @pins.hash ^ @pons.hash
end

#to_sObject



28
29
30
# File 'lib/art-decomp/arch.rb', line 28

def to_s
  "#{pins}/#{pons}"
end