Module: Sevgi::External
- Included in:
- Sevgi
- Defined in:
- lib/sevgi/external.rb,
lib/sevgi/external.rb,
lib/sevgi/external.rb,
lib/sevgi/external.rb
Overview
Externals management DSL for consumers
Instance Method Summary collapse
- #Canvas ⇒ Object
- #Extern(*modules, &block) ⇒ Object
- #Extern!(receiver) ⇒ Object
- #Grid(canvas, unit:, multiple:) ⇒ Object
- #Load(file) ⇒ Object
- #Mixin(mod, document = Graphics::Document::Base, &block) ⇒ Object
- #Point ⇒ Object
- #Ruler ⇒ Object
- #SVG ⇒ Object
- #Verbatim(content) ⇒ Object
Instance Method Details
#Canvas ⇒ Object
45 46 47 |
# File 'lib/sevgi/external.rb', line 45 def Canvas(...) Graphics.Canvas(...) end |
#Extern(*modules, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/sevgi/external.rb', line 25 def Extern(*modules, &block) ::Sevgi::External.tap do |external| external.module_exec(&block) modules.each { external.include(_1) } ::Sevgi.extend(external) end end |
#Extern!(receiver) ⇒ Object
33 34 35 |
# File 'lib/sevgi/external.rb', line 33 def Extern!(receiver, ...) receiver.send(:include, Extern(...)) end |
#Grid(canvas, unit:, multiple:) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/sevgi/external.rb', line 68 def Grid(canvas, unit:, multiple:) ArgumentError.("Must be a Canvas: #{canvas}") unless canvas.is_a?(Graphics::Canvas) Geometry::Grid[ Geometry::Ruler.new(brut: canvas.width, unit:, multiple:, margin: canvas.left), Geometry::Ruler.new(brut: canvas.height, unit:, multiple:, margin: canvas.top) ] end |
#Load(file) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/sevgi/external.rb', line 128 def Load(file) start = ::File.dirname(exclude = caller_locations(1..1).first.path) raise(Error, "Cannot load a file matching: #{file}") unless (location = Locate.(F.qualify(file, EXTENSION), start, exclude:)) Sandbox.load(location.file) end |
#Mixin(mod, document = Graphics::Document::Base, &block) ⇒ Object
49 50 51 52 |
# File 'lib/sevgi/external.rb', line 49 def Mixin(mod, document = Graphics::Document::Base, &block) document.mixture(mod) document.mixture(::Module.new(&block)) if block end |
#Point ⇒ Object
77 78 79 |
# File 'lib/sevgi/external.rb', line 77 def Point(...) Geometry::Point.new(...) end |
#Ruler ⇒ Object
81 82 83 |
# File 'lib/sevgi/external.rb', line 81 def Ruler(...) Geometry::Ruler.new(...) end |
#SVG ⇒ Object
54 55 56 |
# File 'lib/sevgi/external.rb', line 54 def SVG(...) Graphics.SVG(...) end |
#Verbatim(content) ⇒ Object
58 59 60 |
# File 'lib/sevgi/external.rb', line 58 def Verbatim(content) Graphics::Content.verbatim(content) end |