Class: Bulldog::Processor::Base
- Inherits:
-
Object
- Object
- Bulldog::Processor::Base
- Defined in:
- lib/bulldog/processor/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attachment ⇒ Object
readonly
The attachment object being processed.
-
#input_file ⇒ Object
readonly
The name of the original file.
-
#style ⇒ Object
readonly
The current style being processed.
-
#styles ⇒ Object
readonly
The styles to run this processor for.
Instance Method Summary collapse
-
#initialize(attachment, input_file) ⇒ Base
constructor
A new instance of Base.
-
#name ⇒ Object
The name of the attachment being processed.
-
#output_file(style_name) ⇒ Object
The name of the output file for the given style.
-
#process(styles, options = {}, &block) ⇒ Object
Run the given block in the context of this processor, once for each style.
-
#record ⇒ Object
The record being processed.
-
#value ⇒ Object
Return the value of the attachment.
Constructor Details
#initialize(attachment, input_file) ⇒ Base
Returns a new instance of Base.
4 5 6 7 |
# File 'lib/bulldog/processor/base.rb', line 4 def initialize(, input_file) = @input_file = input_file end |
Instance Attribute Details
#attachment ⇒ Object (readonly)
The attachment object being processed.
12 13 14 |
# File 'lib/bulldog/processor/base.rb', line 12 def end |
#input_file ⇒ Object (readonly)
The name of the original file.
36 37 38 |
# File 'lib/bulldog/processor/base.rb', line 36 def input_file @input_file end |
#style ⇒ Object (readonly)
The current style being processed.
84 85 86 |
# File 'lib/bulldog/processor/base.rb', line 84 def style @style end |
#styles ⇒ Object (readonly)
The styles to run this processor for.
17 18 19 |
# File 'lib/bulldog/processor/base.rb', line 17 def styles @styles end |
Instance Method Details
#name ⇒ Object
The name of the attachment being processed.
29 30 31 |
# File 'lib/bulldog/processor/base.rb', line 29 def name .name end |
#output_file(style_name) ⇒ Object
The name of the output file for the given style.
41 42 43 44 45 46 47 |
# File 'lib/bulldog/processor/base.rb', line 41 def output_file(style_name) overrides = {} if (format = styles[style_name][:format]) overrides[:extension] = format end .interpolate_path(style_name, overrides) end |
#process(styles, options = {}, &block) ⇒ Object
Run the given block in the context of this processor, once for each style.
#style will be set to the current style each time the block is called.
Return true if any styles were processed, false otherwise. Subclasses can use this to determine if any processing commands need to be run.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bulldog/processor/base.rb', line 67 def process(styles, ={}, &block) @styles = styles return false if styles.empty? styles.each do |style| @style = style begin process_style(&block) ensure @style = nil end end true end |
#record ⇒ Object
The record being processed.
22 23 24 |
# File 'lib/bulldog/processor/base.rb', line 22 def record .record end |
#value ⇒ Object
Return the value of the attachment.
52 53 54 |
# File 'lib/bulldog/processor/base.rb', line 52 def value record.send(name).value end |