Class: Wordcram::Placer

Inherits:
Object
  • Object
show all
Defined in:
lib/wordcram/placer.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Placer

Returns a new instance of Placer.



3
4
5
# File 'lib/wordcram/placer.rb', line 3

def initialize(&block)
  @block = block
end

Instance Method Details

#place(word, index, count, word_width, word_height, field_width, field_height) ⇒ Object

This method is called from the java side, so I can’t make the arguments a hash key. Blame Java T_T



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/wordcram/placer.rb', line 9

def place(word, index, count, word_width, word_height, field_width, field_height)
  data = {}
  data[:word]         = word
  data[:index]        = index
  data[:count]        = count
  data[:word_width]   = word_width
  data[:word_height]  = word_height
  data[:field_width]  = field_width
  data[:field_height] = field_height

  pos = @block.call(data)

  Processing::PVector.new(pos[0], pos[1])
end