Class: DummyImage::Image
- Inherits:
-
Object
- Object
- DummyImage::Image
- Defined in:
- lib/dummy_image/image.rb
Defined Under Namespace
Modules: ImageBuilder
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
Class Method Summary collapse
Instance Method Summary collapse
- #bgcolor ⇒ Object
- #caption ⇒ Object
- #create_image! ⇒ Object
- #fgcolor ⇒ Object
- #file_path ⇒ Object
- #format ⇒ Object
- #height ⇒ Object
- #image ⇒ Object
- #image_name ⇒ Object
-
#initialize(arguments) ⇒ Image
constructor
A new instance of Image.
- #width ⇒ Object
Constructor Details
#initialize(arguments) ⇒ Image
Returns a new instance of Image.
10 11 12 |
# File 'lib/dummy_image/image.rb', line 10 def initialize arguments @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
4 5 6 |
# File 'lib/dummy_image/image.rb', line 4 def arguments @arguments end |
Class Method Details
.find(arguments) ⇒ Object
6 7 8 |
# File 'lib/dummy_image/image.rb', line 6 def self.find(arguments) new(arguments).image end |
Instance Method Details
#bgcolor ⇒ Object
30 31 32 |
# File 'lib/dummy_image/image.rb', line 30 def bgcolor arguments.bgcolor end |
#caption ⇒ Object
49 50 51 |
# File 'lib/dummy_image/image.rb', line 49 def [width, height].join(" x ") end |
#create_image! ⇒ Object
53 54 55 |
# File 'lib/dummy_image/image.rb', line 53 def create_image! ImageBuilder.build width, height, fgcolor, bgcolor, , file_path end |
#fgcolor ⇒ Object
26 27 28 |
# File 'lib/dummy_image/image.rb', line 26 def fgcolor arguments.fgcolor end |
#file_path ⇒ Object
38 39 40 |
# File 'lib/dummy_image/image.rb', line 38 def file_path ["tmp", image_name].join "/" end |
#format ⇒ Object
34 35 36 |
# File 'lib/dummy_image/image.rb', line 34 def format arguments.format end |
#height ⇒ Object
22 23 24 |
# File 'lib/dummy_image/image.rb', line 22 def height arguments.height end |
#image ⇒ Object
42 43 44 45 46 47 |
# File 'lib/dummy_image/image.rb', line 42 def image unless File.exists? file_path create_image! end image_name end |
#image_name ⇒ Object
14 15 16 |
# File 'lib/dummy_image/image.rb', line 14 def image_name [width, height, fgcolor, bgcolor].join("_") + "." + format end |
#width ⇒ Object
18 19 20 |
# File 'lib/dummy_image/image.rb', line 18 def width arguments.width end |