Class: Pageflow::ZencoderAttachment
- Inherits:
-
Object
- Object
- Pageflow::ZencoderAttachment
- Defined in:
- app/models/pageflow/zencoder_attachment.rb
Instance Attribute Summary collapse
-
#file_name_pattern ⇒ Object
readonly
Returns the value of attribute file_name_pattern.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#styles ⇒ Object
readonly
Returns the value of attribute styles.
Instance Method Summary collapse
- #base_name_pattern ⇒ Object
- #dir_name ⇒ Object
- #format ⇒ Object
-
#initialize(instance, file_name_pattern, options = {}) ⇒ ZencoderAttachment
constructor
A new instance of ZencoderAttachment.
- #original_filename ⇒ Object
- #path ⇒ Object
- #url(url_options = {}) ⇒ Object
- #url_relative_to(attachment) ⇒ Object
Constructor Details
#initialize(instance, file_name_pattern, options = {}) ⇒ ZencoderAttachment
Returns a new instance of ZencoderAttachment.
15 16 17 18 19 20 21 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 15 def initialize(instance, file_name_pattern, = {}) @instance = instance @file_name_pattern = file_name_pattern @options = .reverse_merge() @styles = {} end |
Instance Attribute Details
#file_name_pattern ⇒ Object (readonly)
Returns the value of attribute file_name_pattern.
13 14 15 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 13 def file_name_pattern @file_name_pattern end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
13 14 15 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 13 def instance @instance end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 13 def @options end |
#styles ⇒ Object (readonly)
Returns the value of attribute styles.
13 14 15 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 13 def styles @styles end |
Instance Method Details
#base_name_pattern ⇒ Object
31 32 33 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 31 def base_name_pattern File.basename(file_name_pattern) end |
#dir_name ⇒ Object
27 28 29 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 27 def dir_name File.dirname(path) end |
#format ⇒ Object
23 24 25 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 23 def format [:format] end |
#original_filename ⇒ Object
35 36 37 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 35 def original_filename [file_name_pattern.gsub('{{number}}', '0'), [:format]].compact * '.' end |
#path ⇒ Object
39 40 41 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 39 def path Paperclip::Interpolations.interpolate([:path], self, 'default') end |
#url(url_options = {}) ⇒ Object
43 44 45 46 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 43 def url( = {}) ensure_default_protocol(interpolate(url_pattern()), ) end |
#url_relative_to(attachment) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'app/models/pageflow/zencoder_attachment.rb', line 48 def url_relative_to() dir_path = File.dirname(URI.parse(.url).path) unless URI.parse(url).path.start_with?(dir_path) raise("Could not generate relative url for #{url} based on #{.url}.") end url.split("#{dir_path}/", 2).last end |