Class: Doge

Inherits:
Object
  • Object
show all
Defined in:
lib/doge.rb,
lib/doge/version.rb

Constant Summary collapse

VERSION =
"1.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_path = nil, &block) ⇒ Doge

Returns a new instance of Doge.



8
9
10
11
12
13
# File 'lib/doge.rb', line 8

def initialize(image_path = nil, &block)
  image_path ||= File.expand_path('doge/images/doge.jpg', File.dirname(__FILE__))
  @image = Magick::ImageList.new(image_path)
  @occupied = []
  instance_eval &block if block
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



6
7
8
# File 'lib/doge.rb', line 6

def image
  @image
end

Instance Method Details

#wuff(term) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/doge.rb', line 15

def wuff(term)
  text = image_text
  metrics = text.get_type_metrics(@image, term)
  horizontal_padding = @image.columns * 0.1
  horizontal_top = @image.columns - horizontal_padding - metrics.width
  height = metrics.height.round + 5 #padding
  @image.annotate(text, 0,0, Random.rand(horizontal_padding..horizontal_top), y_for_height(height), term)
  self
end