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.



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

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.



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

def path
  @path
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.rootObject



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

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

.routeObject



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

def Placeholder.route
  "/assets"
end

Instance Method Details

#absolute?Boolean

Returns:

  • (Boolean)


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

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

#basenameObject



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

def basename
  File.basename(self)
end

#default_pathObject



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

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

#default_urlObject



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

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