Module: Sumi::Graphics::Mixtures::Save
- Defined in:
- graphics/lib/sumi/graphics/mixtures/save.rb
Overview
DSL helpers for writing rendered SVG output.
Instance Method Summary collapse
-
#Out(**kwargs) ⇒ nil
Writes rendered SVG to standard output.
-
#Save(path = nil, default: nil, backup_suffix: nil, **kwargs) {|content| ... } ⇒ String?
Saves rendered SVG when its content differs from the destination.
-
#Write(path, **kwargs) {|content| ... } ⇒ String?
Writes rendered SVG to a path.
Instance Method Details
#Out(**kwargs) ⇒ nil
Writes rendered SVG to standard output.
51 52 53 |
# File 'graphics/lib/sumi/graphics/mixtures/save.rb', line 51 def Out(**kwargs) F.out(self.(**kwargs)) end |
#Save(path = nil, default: nil, backup_suffix: nil, **kwargs) {|content| ... } ⇒ String?
Saves rendered SVG when its content differs from the destination. Relative destinations are expanded before being returned. When a non-empty backup suffix is given, an existing destination is copied immediately before replacement. Unchanged saves leave both files untouched. Missing parent directories are created. An existing directory target uses the default file name.
75 76 77 78 79 80 |
# File 'graphics/lib/sumi/graphics/mixtures/save.rb', line 75 def Save(path = nil, default: nil, backup_suffix: nil, **kwargs, &filter) default = F.subext(EXT, caller_locations(1..1).first.path) if default.nil? path = F.output_path(path, default:, context: "Save") Writer.(path, self.(**kwargs), backup_suffix:, &filter) end |
#Write(path, **kwargs) {|content| ... } ⇒ String?
Writes rendered SVG to a path. Missing parent directories are created. Unlike #Save, a directory is not treated as a request for a default file name.
96 97 98 99 100 101 |
# File 'graphics/lib/sumi/graphics/mixtures/save.rb', line 96 def Write(path, **kwargs, &filter) path = F.path(path, context: "Write path") ArgumentError.("Write path must name a file") if ::File.directory?(path) Writer.(path, self.(**kwargs), &filter) end |