Class: IML::Formatter
- Inherits:
-
Object
- Object
- IML::Formatter
- Defined in:
- lib/iml/formatter.rb
Instance Method Summary collapse
Instance Method Details
#call(media, format: nil) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/iml/formatter.rb', line 4 def call(media, format: nil) format_string = format || media.class::DEFAULT_FORMAT media.class::PLACEHOLDERS.each do |placeholder, attribute| format_string = format_string.gsub(placeholder, media.send(attribute).to_s) end format_string end |
#pathname(media, format: nil, target: nil) ⇒ Object
12 13 14 15 |
# File 'lib/iml/formatter.rb', line 12 def pathname(media, format: nil, target: nil) formatted = call(media, format: format) target ? Pathname(target) + Pathname(formatted) : Pathname(formatted) end |