Module: Seamus::StandardAdditions
- Included in:
- File::Application, File::Audio, File::Image, File::Text, File::Video
- Defined in:
- lib/seamus/standard_additions.rb
Instance Method Summary collapse
- #[](attribute) ⇒ Object
- #add_inspection_attributes(*args) ⇒ Object
- #attributes ⇒ Object
- #content_type ⇒ Object
-
#md5 ⇒ Object
Returns a Digest::MD5 instance.
- #md5_base64_encoded ⇒ Object
- #md5_digest ⇒ Object
- #size ⇒ Object
Instance Method Details
#[](attribute) ⇒ Object
31 32 33 |
# File 'lib/seamus/standard_additions.rb', line 31 def [](attribute) attributes[attribute.to_sym] end |
#add_inspection_attributes(*args) ⇒ Object
25 26 27 28 29 |
# File 'lib/seamus/standard_additions.rb', line 25 def add_inspection_attributes(*args) args.select{|arg| arg.respond_to?(:to_sym) }.each do |arg| inspection_attributes.push arg end end |
#attributes ⇒ Object
35 36 37 38 39 40 |
# File 'lib/seamus/standard_additions.rb', line 35 def attributes @attributes ||= inspection_attributes.inject({}) do |h, i| h[i] = self.send(i) if self.respond_to?(i) h end end |
#content_type ⇒ Object
21 22 23 |
# File 'lib/seamus/standard_additions.rb', line 21 def content_type MimeTable.lookup_by_extension(extension).to_s end |
#md5 ⇒ Object
Returns a Digest::MD5 instance
5 6 7 |
# File 'lib/seamus/standard_additions.rb', line 5 def md5 @md5 ||= Digest::MD5.file(self.path) end |
#md5_base64_encoded ⇒ Object
13 14 15 |
# File 'lib/seamus/standard_additions.rb', line 13 def md5_base64_encoded Base64.encode64(md5_digest).strip end |
#md5_digest ⇒ Object
9 10 11 |
# File 'lib/seamus/standard_additions.rb', line 9 def md5_digest md5.digest end |
#size ⇒ Object
17 18 19 |
# File 'lib/seamus/standard_additions.rb', line 17 def size stat.size end |