Module: Dieses::Application::Sheets
- Defined in:
- lib/dieses/application/sheets.rb,
lib/dieses/application/sheets/graph.rb,
lib/dieses/application/sheets/lined.rb,
lib/dieses/application/sheets/print.rb,
lib/dieses/application/sheets/ruled.rb,
lib/dieses/application/sheets/table.rb,
lib/dieses/application/sheets/cursive.rb,
lib/dieses/application/sheets/italics.rb,
lib/dieses/application/sheets/lettering.rb,
lib/dieses/application/sheets/thumbnail.rb,
lib/dieses/application/sheets/spencerian.rb,
lib/dieses/application/sheets/copperplate.rb
Defined Under Namespace
Classes: Copperplate, Cursive, Graph, Italics, Lettering, Lined, Print, Ruled, Spencerian, Table, Thumbnail
Class Method Summary
collapse
Class Method Details
.available ⇒ Object
35
36
37
38
39
|
# File 'lib/dieses/application/sheets.rb', line 35
def self.available
@registry.sort.to_h.transform_values do |proto|
proto.derivate(variants: proto.klass.variants.values.map(&:derivate))
end
end
|
.available?(name) ⇒ Boolean
8
9
10
|
# File 'lib/dieses/application/sheets.rb', line 8
def self.available?(name)
@registry.key? name.to_sym
end
|
.call(name, paper, variant: nil, param: {}) ⇒ Object
31
32
33
|
# File 'lib/dieses/application/sheets.rb', line 31
def self.call(name, paper, variant: nil, param: {})
sheet(name).new(paper, variant, **param).call
end
|
.defaults ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/dieses/application/sheets.rb', line 41
def self.defaults
{}.tap do |defaults|
available.each_key do |name|
defaults[name] = sheet(name).default_variant
end
end
end
|
.dump(prefix: '') ⇒ Object
49
50
51
52
53
|
# File 'lib/dieses/application/sheets.rb', line 49
def self.dump(prefix: '')
Sheet::Proto.formatted(*available.values, prefix: prefix) do |proto|
Sheet::Proto.formatted(*proto.variants, prefix: prefix * 2)
end
end
|
.proto(name) ⇒ Object
21
22
23
24
25
|
# File 'lib/dieses/application/sheets.rb', line 21
def self.proto(name)
raise Error, "No such sheet available: #{name}" unless @registry[name = name.to_sym]
@registry[name]
end
|
.register(name, klass:, desc:, default: nil) ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/dieses/application/sheets.rb', line 12
def self.register(name, klass:, desc:, default: nil)
@registry[name = name.to_sym] = Sheet::Proto.new(name: name,
desc: desc,
klass: klass,
default: default).tap do |proto|
klass.proto proto
end
end
|
.sheet(name) ⇒ Object
27
28
29
|
# File 'lib/dieses/application/sheets.rb', line 27
def self.sheet(name)
proto(name).klass
end
|