Class: Yearbook::Image
- Inherits:
-
Object
- Object
- Yearbook::Image
- Defined in:
- lib/yearbook/image.rb
Constant Summary collapse
- CLIPPER_REGEX =
META STUFF
/^(clip_and_print(?:_best)?|clip)_(\w+)$/
Instance Attribute Summary collapse
-
#clips ⇒ Object
readonly
Returns the value of attribute clips.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#clip(obj_type, *args, &blk) ⇒ Object
args is empty for now…
-
#clip_and_print(obj_type, filename, *args, &blk) ⇒ Object
convenience method.
-
#clip_and_print_best(obj_type, filename, *args, &blk) ⇒ Object
convenience method.
- #clipped? ⇒ Boolean
-
#initialize(fname) ⇒ Image
constructor
A new instance of Image.
- #method_missing(foo, *args, &blk) ⇒ Object
-
#print(fname, &blk) ⇒ Object
just the original image.
- #print_best_clip(fname, &blk) ⇒ Object
-
#print_clips(fname, &blk) ⇒ Object
print all the clips.
- #respond_to?(foo, include_private = false) ⇒ Boolean
Constructor Details
#initialize(fname) ⇒ Image
Returns a new instance of Image.
9 10 11 |
# File 'lib/yearbook/image.rb', line 9 def initialize(fname) @filename = fname end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(foo, *args, &blk) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/yearbook/image.rb', line 57 def method_missing(foo, *args, &blk) f = foo.to_s # e.g. clip_faces if f =~ CLIPPER_REGEX self.send $1, $2, *args, &blk else super end end |
Instance Attribute Details
#clips ⇒ Object (readonly)
Returns the value of attribute clips.
8 9 10 |
# File 'lib/yearbook/image.rb', line 8 def clips @clips end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/yearbook/image.rb', line 8 def filename @filename end |
Instance Method Details
#clip(obj_type, *args, &blk) ⇒ Object
args is empty for now…
16 17 18 |
# File 'lib/yearbook/image.rb', line 16 def clip(obj_type, *args, &blk) @clips = detect_and_collect(cv_image, obj_type) end |
#clip_and_print(obj_type, filename, *args, &blk) ⇒ Object
convenience method
40 41 42 43 44 |
# File 'lib/yearbook/image.rb', line 40 def clip_and_print(obj_type, filename, *args, &blk) clip(obj_type, *args, &blk) print_clips(filename) end |
#clip_and_print_best(obj_type, filename, *args, &blk) ⇒ Object
convenience method
47 48 49 50 51 |
# File 'lib/yearbook/image.rb', line 47 def clip_and_print_best(obj_type, filename, *args, &blk) clip(obj_type, *args, &blk) print_best_clip(filename) end |
#clipped? ⇒ Boolean
23 |
# File 'lib/yearbook/image.rb', line 23 def clipped?; @clips.count > 0; end |
#print(fname, &blk) ⇒ Object
just the original image
26 27 28 |
# File 'lib/yearbook/image.rb', line 26 def print(fname, &blk) write_images(magick_image, fname, &blk) end |
#print_best_clip(fname, &blk) ⇒ Object
35 36 37 |
# File 'lib/yearbook/image.rb', line 35 def print_best_clip(fname, &blk) write_images(constitute_best_clip, fname, &blk) end |
#print_clips(fname, &blk) ⇒ Object
print all the clips
31 32 33 |
# File 'lib/yearbook/image.rb', line 31 def print_clips(fname, &blk) write_images(constitute_clips, fname, &blk) end |
#respond_to?(foo, include_private = false) ⇒ Boolean
67 68 69 |
# File 'lib/yearbook/image.rb', line 67 def respond_to?(foo, include_private=false) return foo.to_s =~ CLIPPER_REGEX ? true : super(foo, include_private) end |