Class: SlippyTilesScorer::Score
- Inherits:
-
Object
- Object
- SlippyTilesScorer::Score
- Defined in:
- lib/slippy_tiles_scorer.rb
Overview
Score class to calculate the score of a collection of points (x, y)
Instance Attribute Summary collapse
-
#tiles_x_y ⇒ Object
Returns the value of attribute tiles_x_y.
Instance Method Summary collapse
- #clusters(tiles_x_y: @tiles_x_y) ⇒ Object
-
#initialize(tiles_x_y: Set.new) ⇒ Score
constructor
A new instance of Score.
- #max_square(x:, y:, tiles_x_y: @tiles_x_y) ⇒ Object
- #max_squares(tiles_x_y: @tiles_x_y, min_size: 3) ⇒ Object
- #steps_fulfilled?(x:, y:, steps:) ⇒ Boolean
- #valid? ⇒ Boolean
- #visited(tiles_x_y: @tiles_x_y) ⇒ Object
Constructor Details
#initialize(tiles_x_y: Set.new) ⇒ Score
Returns a new instance of Score.
15 16 17 |
# File 'lib/slippy_tiles_scorer.rb', line 15 def initialize(tiles_x_y: Set.new) @tiles_x_y = tiles_x_y end |
Instance Attribute Details
#tiles_x_y ⇒ Object
Returns the value of attribute tiles_x_y.
13 14 15 |
# File 'lib/slippy_tiles_scorer.rb', line 13 def tiles_x_y @tiles_x_y end |
Instance Method Details
#clusters(tiles_x_y: @tiles_x_y) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/slippy_tiles_scorer.rb', line 26 def clusters(tiles_x_y: @tiles_x_y) service = SlippyTilesScorer::Cluster.new(tiles_x_y: tiles_x_y) result = service.clusters result[:clusters_of_cluster_tiles] = SlippyTilesScorer::Cluster.new(tiles_x_y: result[:cluster_tiles]).clusters[:clusters] result end |
#max_square(x:, y:, tiles_x_y: @tiles_x_y) ⇒ Object
34 35 36 |
# File 'lib/slippy_tiles_scorer.rb', line 34 def max_square(x:, y:, tiles_x_y: @tiles_x_y) SlippyTilesScorer::MaxSquare.new(tiles_x_y: tiles_x_y).max_square(x: x, y: y) end |
#max_squares(tiles_x_y: @tiles_x_y, min_size: 3) ⇒ Object
38 39 40 |
# File 'lib/slippy_tiles_scorer.rb', line 38 def max_squares(tiles_x_y: @tiles_x_y, min_size: 3) SlippyTilesScorer::MaxSquare.new(tiles_x_y: tiles_x_y).max_squares(min_size: min_size) end |
#steps_fulfilled?(x:, y:, steps:) ⇒ Boolean
42 43 44 |
# File 'lib/slippy_tiles_scorer.rb', line 42 def steps_fulfilled?(x:, y:, steps:) SlippyTilesScorer::MaxSquare.new(tiles_x_y: @tiles_x_y).steps_fulfilled?(x: x, y: y, steps: steps) end |
#valid? ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/slippy_tiles_scorer.rb', line 19 def valid? return true if @tiles_x_y.empty? raise ArgumentError, "@tiles_x_y must be a Set" unless @tiles_x_y.is_a?(Set) set_of_arrays? && set_of_arrays_of_integers? end |
#visited(tiles_x_y: @tiles_x_y) ⇒ Object
46 47 48 |
# File 'lib/slippy_tiles_scorer.rb', line 46 def visited(tiles_x_y: @tiles_x_y) tiles_x_y.size end |