Module: Sevgi::Toplevel
- Included in:
- Sevgi
- Defined in:
- lib/sevgi/toplevel.rb,
lib/sevgi/toplevel/derender.rb,
lib/sevgi/toplevel/executor.rb,
lib/sevgi/toplevel/function.rb,
lib/sevgi/toplevel/geometry.rb,
lib/sevgi/toplevel/graphics.rb,
lib/sevgi/toplevel/sundries.rb
Overview
Shared implementation for the full Sevgi top-level DSL.
This module is installed by include Sevgi or extend Sevgi; it should not
normally be included directly.
Class Attribute Summary collapse
-
.constants ⇒ Object
readonly
Returns the value of attribute constants.
Class Method Summary collapse
-
.extended(base) ⇒ void
private
Injects promoted constants when the DSL is extended by a module.
-
.included(base) ⇒ void
private
Injects promoted constants when the DSL is included in a module or class.
Instance Method Summary collapse
-
#Decompile(file, id = nil) ⇒ Sevgi::Derender::Node
Converts an SVG/XML file into a derender node.
-
#Derender(file, id = nil) ⇒ String
Converts an SVG/XML file into Sevgi DSL Ruby source.
-
#Grid(canvas, unit:, multiple:) ⇒ Sevgi::Sundries::Grid
Builds a drawable grid from a graphics canvas.
-
#Load(*files) ⇒ Array<String>
Loads one or more Sevgi files relative to the caller's source file.
- #Mixin ⇒ Object
-
#Paper(width, height, name = :custom, unit: "mm") ⇒ Symbol
Defines or validates a named paper profile for DSL use.
-
#Paper!(width, height, name = :custom, unit: "mm") ⇒ Symbol
Defines or overwrites a named paper profile for DSL use.
Class Attribute Details
.constants ⇒ Object (readonly)
Returns the value of attribute constants.
14 15 16 |
# File 'lib/sevgi/toplevel.rb', line 14 def constants @constants end |
Class Method Details
.extended(base) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Constants are promoted only to modules/classes. Extending an ordinary object installs methods without
writing constants to Object.
This method returns an undefined value.
Injects promoted constants when the DSL is extended by a module.
50 51 52 53 |
# File 'lib/sevgi/toplevel.rb', line 50 def self.extended(base) super inject(base) end |
.included(base) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Injects promoted constants when the DSL is included in a module or class.
39 40 41 42 |
# File 'lib/sevgi/toplevel.rb', line 39 def self.included(base) super inject(base) end |
Instance Method Details
#Decompile(file, id = nil) ⇒ Sevgi::Derender::Node
Converts an SVG/XML file into a derender node.
13 |
# File 'lib/sevgi/toplevel/derender.rb', line 13 def Decompile(file, id = nil) = Derender.decompile_file(file, id:) |
#Derender(file, id = nil) ⇒ String
Converts an SVG/XML file into Sevgi DSL Ruby source.
21 |
# File 'lib/sevgi/toplevel/derender.rb', line 21 def Derender(file, id = nil) = Derender.derender_file(file, id:) |
#Grid(canvas, unit:, multiple:) ⇒ Sevgi::Sundries::Grid
Builds a drawable grid from a graphics canvas.
16 17 18 19 20 21 22 23 |
# File 'lib/sevgi/toplevel/sundries.rb', line 16 def Grid(canvas, unit:, multiple:) ArgumentError.("Must be a Canvas: #{canvas}") unless canvas.is_a?(Graphics::Canvas) Sundries::Grid[ Sundries::Ruler.new(brut: canvas.width, unit:, multiple:, margin: canvas.left), Sundries::Ruler.new(brut: canvas.height, unit:, multiple:, margin: canvas.top) ] end |
#Load(*files) ⇒ Array<String>
Load resolves against the active executor scope in the current fiber.
Loads one or more Sevgi files relative to the caller's source file.
35 36 37 38 39 40 41 42 43 |
# File 'lib/sevgi/toplevel/executor.rb', line 35 def Load(*files) start = ::File.dirname(caller_locations(1..1).first.path) files.each do |file| location = F.locate(file, start, exclude: start) ::Sevgi::Executor.load(location.file) end end |
#Mixin(mod, document = Sevgi::Graphics::Document::Base) { ... } ⇒ void #Mixin(document = Sevgi::Graphics::Document::Base) { ... } ⇒ Module
24 |
# File 'lib/sevgi/toplevel/graphics.rb', line 24 def Mixin(...) = Graphics::Mixtures.mixin(...) |
#Paper(width, height, name = :custom, unit: "mm") ⇒ Symbol
35 |
# File 'lib/sevgi/toplevel/graphics.rb', line 35 def Paper(...) = Graphics.paper(...) |
#Paper!(width, height, name = :custom, unit: "mm") ⇒ Symbol
46 |
# File 'lib/sevgi/toplevel/graphics.rb', line 46 def Paper!(...) = Graphics.paper!(...) |