Class: BinPacking::ScoreBoardEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/bin_packing/score_board_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bin, box) ⇒ ScoreBoardEntry

Returns a new instance of ScoreBoardEntry.



5
6
7
8
9
# File 'lib/bin_packing/score_board_entry.rb', line 5

def initialize(bin, box)
  @bin = bin
  @box = box
  @score = nil
end

Instance Attribute Details

#binObject (readonly)

Returns the value of attribute bin.



3
4
5
# File 'lib/bin_packing/score_board_entry.rb', line 3

def bin
  @bin
end

#boxObject (readonly)

Returns the value of attribute box.



3
4
5
# File 'lib/bin_packing/score_board_entry.rb', line 3

def box
  @box
end

#scoreObject (readonly)

Returns the value of attribute score.



3
4
5
# File 'lib/bin_packing/score_board_entry.rb', line 3

def score
  @score
end

Instance Method Details

#calculateObject



11
12
13
# File 'lib/bin_packing/score_board_entry.rb', line 11

def calculate
  @score = @bin.score_for(@box)
end

#fit?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/bin_packing/score_board_entry.rb', line 15

def fit?
  !@score.is_blank?
end