Class: Bloggit::Media
- Inherits:
-
Object
- Object
- Bloggit::Media
- Defined in:
- lib/bloggit/media.rb
Overview
Media
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#full_path ⇒ Object
readonly
Returns the value of attribute full_path.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
-
.from_file(path, site) ⇒ Object
Creates a Media object from an image on the filesystem.
Instance Method Summary collapse
- #create_thumbnail(size = nil) ⇒ Object
-
#initialize(path, site) ⇒ Media
constructor
A new instance of Media.
- #permalink ⇒ Object
- #thumbnail_path(size = nil) ⇒ Object
Constructor Details
#initialize(path, site) ⇒ Media
Returns a new instance of Media.
9 10 11 12 13 14 15 16 17 |
# File 'lib/bloggit/media.rb', line 9 def initialize(path, site) @site = site @full_path = path @relative_path = path.gsub(File.join(site.base_path, 'media', ''), '') # Read file info and set Media properties... @filename = File.basename(path) @ext = File.extname(path) # TODO: name, size, dimensions end |
Instance Attribute Details
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
7 8 9 |
# File 'lib/bloggit/media.rb', line 7 def dimensions @dimensions end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
7 8 9 |
# File 'lib/bloggit/media.rb', line 7 def ext @ext end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
7 8 9 |
# File 'lib/bloggit/media.rb', line 7 def filename @filename end |
#full_path ⇒ Object (readonly)
Returns the value of attribute full_path.
7 8 9 |
# File 'lib/bloggit/media.rb', line 7 def full_path @full_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/bloggit/media.rb', line 7 def name @name end |
#relative_path ⇒ Object (readonly)
Returns the value of attribute relative_path.
7 8 9 |
# File 'lib/bloggit/media.rb', line 7 def relative_path @relative_path end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
7 8 9 |
# File 'lib/bloggit/media.rb', line 7 def site @site end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'lib/bloggit/media.rb', line 7 def size @size end |
Class Method Details
.from_file(path, site) ⇒ Object
Creates a Media object from an image on the filesystem
33 34 35 36 37 |
# File 'lib/bloggit/media.rb', line 33 def from_file(path, site) path = File.(path) raise "File must exist" unless File.exists?( path ) new( path, site ) end |
Instance Method Details
#create_thumbnail(size = nil) ⇒ Object
22 23 |
# File 'lib/bloggit/media.rb', line 22 def create_thumbnail(size=nil) end |
#permalink ⇒ Object
25 26 27 |
# File 'lib/bloggit/media.rb', line 25 def permalink "media/#{@relative_path}" end |
#thumbnail_path(size = nil) ⇒ Object
19 20 |
# File 'lib/bloggit/media.rb', line 19 def thumbnail_path(size=nil) end |