Class: Ires::Service
- Inherits:
-
Object
- Object
- Ires::Service
- Defined in:
- lib/ires/service.rb
Class Method Summary collapse
-
.path(path, width: nil, height: nil, type: Type::ALL, mode: Mode::RESIZE, expire: 30.days) ⇒ String
Resize image path.
Class Method Details
.path(path, width: nil, height: nil, type: Type::ALL, mode: Mode::RESIZE, expire: 30.days) ⇒ String
Resize image path
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ires/service.rb', line 11 def path(path, width: nil, height: nil, type: Type::ALL, mode: Mode::RESIZE, expire: 30.days) raise StandardError, "#{path} is not string." unless path.kind_of?(String) raise ArgumentError, "Either width or height is required." if width.nil? && height.nil? os = Ires::Os.current return nil if os.nil? raise StandardError, "Nil location provided. Can't build URI." if path.nil? return path if path.empty? full_path = image_full_path(path.to_s) # if no image or could not find file path then perform the same action as 'image_tag' return nil if invalid_path?(full_path) expiration_date = expiration_date(expire) dir = image_dir ires_element = { path: full_path, width: width || 0, height: height || 0, mode: mode, type: type, dir: dir, expire: expiration_date } ires_image_path(ires_element) end |