Class: MarkdownExec::SavedAsset
Overview
SavedAsset
This class provides utilities to format and derive asset names based on given parameters. The ‘script_name` method derives a name for a script based on filename, prefix, time, and blockname. Similarly, the `stdout_name` method derives a name for stdout redirection.
Constant Summary collapse
- DEFAULT_FTIME =
'%F-%H-%M-%S'
- FILE_BLOCK_SEP =
','
- JOIN_STR =
'_'
- MARK_STR =
'~'
Instance Method Summary collapse
-
#generate_name ⇒ String
Generates a formatted name based on the provided parameters.
-
#initialize(saved_asset_format:, blockname: nil, exts: nil, filename: nil, ftime: DEFAULT_FTIME, join_str: nil, mark: nil, prefix: nil, time: nil) ⇒ SavedAsset
constructor
A new instance of SavedAsset.
Constructor Details
#initialize(saved_asset_format:, blockname: nil, exts: nil, filename: nil, ftime: DEFAULT_FTIME, join_str: nil, mark: nil, prefix: nil, time: nil) ⇒ SavedAsset
Returns a new instance of SavedAsset.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/saved_assets.rb', line 29 def initialize( saved_asset_format:, blockname: nil, exts: nil, filename: nil, ftime: DEFAULT_FTIME, join_str: nil, mark: nil, prefix: nil, time: nil ) @filename = filename.present? ? filename.pub_name : '*' @prefix = prefix || '*' @time = time ? time.strftime(ftime) : '*' @blockname = blockname ? blockname.pub_name : '*' @exts = exts || '.*' @mark = mark || MARK_STR @join_str = join_str || JOIN_STR @saved_asset_format = saved_asset_format end |
Instance Method Details
#generate_name ⇒ String
Generates a formatted name based on the provided parameters.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/saved_assets.rb', line 47 def generate_name # !!ey ({saved_asset_format: @saved_asset_format, blockname: @blockname, exts: @exts, filename: @filename, join: @join_str, mark: @mark, prefix: @prefix, time: @time }) format( @saved_asset_format, { blockname: @blockname, exts: @exts, filename: @filename, join: @join_str, mark: @mark, prefix: @prefix, time: @time } ) end |