Class: Dieses::Application::Mixins::Scribes

Inherits:
Module
  • Object
show all
Defined in:
lib/dieses/application/mixins/scribes.rb

Defined Under Namespace

Modules: Bundle, ClassMethods, InstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Scribes

Returns a new instance of Scribes.



13
14
15
16
# File 'lib/dieses/application/mixins/scribes.rb', line 13

def initialize(type)
  super()
  @type = type.to_sym
end

Class Method Details

.[](type) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
# File 'lib/dieses/application/mixins/scribes.rb', line 7

def self.[](type)
  raise ArgumentError, "No such Scribes type available: #{type}" unless Bundle.method_defined? type

  new(type)
end

Instance Method Details

#included(base) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/dieses/application/mixins/scribes.rb', line 64

def included(base)
  base.include Lines

  base.extend ClassMethods
  base.include InstanceMethods

  base.extend Bundle

  base.variate_scribes(unit: @unit, ratio: @ratio, gap: @gap) if @unit

  base.send(@type)
end

#with(unit:, ratio: [1/1r], gap: [0]) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/dieses/application/mixins/scribes.rb', line 18

def with(unit:, ratio: [1/1r], gap: [0])
  tap do
    @unit  = unit
    @ratio = ratio
    @gap   = gap
  end
end