Class: Dao::Upload::Placeholder

Inherits:
String
  • Object
show all
Defined in:
lib/dao/upload.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(placeholder = '', options = {}) ⇒ Placeholder

Returns a new instance of Placeholder.



383
384
385
386
387
388
# File 'lib/dao/upload.rb', line 383

def initialize(placeholder = '', options = {})
  replace(placeholder.to_s)
  options.to_options!
  @url = options[:url] || default_url
  @path = options[:path] || default_path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



381
382
383
# File 'lib/dao/upload.rb', line 381

def path
  @path
end

#urlObject

Returns the value of attribute url.



380
381
382
# File 'lib/dao/upload.rb', line 380

def url
  @url
end

Class Method Details

.rootObject



376
377
378
# File 'lib/dao/upload.rb', line 376

def Placeholder.root
  File.join(Rails.root, "app", "assets", "placeholders")
end

.routeObject



372
373
374
# File 'lib/dao/upload.rb', line 372

def Placeholder.route
  "/assets"
end

Instance Method Details

#absolute?Boolean

Returns:

  • (Boolean)


404
405
406
# File 'lib/dao/upload.rb', line 404

def absolute?
  self =~ %r|\A([^:/]++:/)?/|
end

#basenameObject



400
401
402
# File 'lib/dao/upload.rb', line 400

def basename
  File.basename(self)
end

#default_pathObject



395
396
397
398
# File 'lib/dao/upload.rb', line 395

def default_path
  return nil if blank?
  absolute? ? nil : File.join(Placeholder.root, self)
end

#default_urlObject



390
391
392
393
# File 'lib/dao/upload.rb', line 390

def default_url
  return nil if blank?
  absolute? ? self : File.join(Placeholder.route, self)
end