Class: Doge
- Inherits:
-
Object
- Object
- Doge
- Defined in:
- lib/doge.rb,
lib/doge/version.rb
Constant Summary collapse
- VERSION =
"1.0.2"
Instance Attribute Summary collapse
-
#image ⇒ Object
readonly
Returns the value of attribute image.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Doge
constructor
A new instance of Doge.
- #wuff(term) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Doge
Returns a new instance of Doge.
8 9 10 11 12 |
# File 'lib/doge.rb', line 8 def initialize(&block) @image = Magick::ImageList.new(File.('doge/images/doge.jpg', File.dirname(__FILE__))) @occupied = [] instance_eval &block if block end |
Instance Attribute Details
#image ⇒ Object (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
14 15 16 17 18 19 20 21 22 |
# File 'lib/doge.rb', line 14 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 |