Module: Sevgi::Graphics::Mixtures::Save
- Defined in:
- lib/sevgi/graphics/mixtures/save.rb
Overview
DSL helpers for writing rendered SVG output.
Constant Summary collapse
- EXT =
Default SVG extension.
".svg"
Instance Method Summary collapse
-
#Out(**kwargs) {|content| ... } ⇒ Object
Writes rendered SVG to standard output.
-
#Save(path = nil, default: nil, backup_suffix: nil) {|content| ... } ⇒ Object
Saves rendered SVG to a path derived from the caller by default.
-
#Write(path, **kwargs) {|content| ... } ⇒ Object
Writes rendered SVG to a path.
Instance Method Details
#Out(**kwargs) {|content| ... } ⇒ Object
Writes rendered SVG to standard output.
19 20 21 |
# File 'lib/sevgi/graphics/mixtures/save.rb', line 19 def Out(**kwargs, &filter) F.out(self.(**kwargs), &filter) end |
#Save(path = nil, default: nil, backup_suffix: nil) {|content| ... } ⇒ Object
Saves rendered SVG to a path derived from the caller by default.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sevgi/graphics/mixtures/save.rb', line 31 def Save(path = nil, default: nil, backup_suffix: nil, &filter) default ||= F.subext(EXT, caller_locations(1..1).first.path) if path ::File.directory?(path) ? ::File.join(path, ::File.basename(default)) : path else default end => path ::FileUtils.mkdir_p(::File.dirname(path)) if backup_suffix && !backup_suffix.empty? && ::File.exist?(path) ::FileUtils.cp(path, "#{path}#{backup_suffix}") end Write(path, &filter) end |
#Write(path, **kwargs) {|content| ... } ⇒ Object
Writes rendered SVG to a path.
55 56 57 |
# File 'lib/sevgi/graphics/mixtures/save.rb', line 55 def Write(path, **kwargs, &filter) F.out(self.(**kwargs), path, &filter) end |