Class: Pageflow::ZencoderAttachment

Inherits:
Object
  • Object
show all
Defined in:
app/models/pageflow/zencoder_attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance, file_name_pattern, options = {}) ⇒ ZencoderAttachment

Returns a new instance of ZencoderAttachment.



14
15
16
17
18
19
20
# File 'app/models/pageflow/zencoder_attachment.rb', line 14

def initialize(instance, file_name_pattern, options = {})
  @instance = instance
  @file_name_pattern = file_name_pattern
  @options = options.reverse_merge(default_options)

  @styles = {}
end

Instance Attribute Details

#file_name_patternObject (readonly)

Returns the value of attribute file_name_pattern.



12
13
14
# File 'app/models/pageflow/zencoder_attachment.rb', line 12

def file_name_pattern
  @file_name_pattern
end

#instanceObject (readonly)

Returns the value of attribute instance.



12
13
14
# File 'app/models/pageflow/zencoder_attachment.rb', line 12

def instance
  @instance
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'app/models/pageflow/zencoder_attachment.rb', line 12

def options
  @options
end

#stylesObject (readonly)

Returns the value of attribute styles.



12
13
14
# File 'app/models/pageflow/zencoder_attachment.rb', line 12

def styles
  @styles
end

Instance Method Details

#base_name_patternObject



30
31
32
# File 'app/models/pageflow/zencoder_attachment.rb', line 30

def base_name_pattern
  File.basename(file_name_pattern)
end

#dir_nameObject



26
27
28
# File 'app/models/pageflow/zencoder_attachment.rb', line 26

def dir_name
  File.dirname(path)
end

#formatObject



22
23
24
# File 'app/models/pageflow/zencoder_attachment.rb', line 22

def format
  options[:format]
end

#original_filenameObject



34
35
36
# File 'app/models/pageflow/zencoder_attachment.rb', line 34

def original_filename
  [file_name_pattern.gsub('{{number}}', '0'), options[:format]].compact * '.'
end

#pathObject



38
39
40
# File 'app/models/pageflow/zencoder_attachment.rb', line 38

def path
  Paperclip::Interpolations.interpolate(options[:path], self, 'default')
end

#url(url_options = {}) ⇒ Object



42
43
44
45
# File 'app/models/pageflow/zencoder_attachment.rb', line 42

def url(url_options = {})
  ensure_default_protocol(interpolate(url_pattern(url_options)),
                          url_options)
end