Class: Dieses::Application::Sheet::Proto

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/dieses/application/sheet.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(**kwargs) ⇒ Object



53
54
55
# File 'lib/dieses/application/sheet.rb', line 53

def self.call(**kwargs)
  new(**kwargs)
end

.formatted(*protos, prefix: EMPTY_STRING) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/dieses/application/sheet.rb', line 57

def self.formatted(*protos, prefix: EMPTY_STRING)
  longest_length = protos.map { |proto| proto.name.to_s.length }.max

  protos.map do |proto|
    lines = ["#{prefix}#{proto.name.to_s.ljust(longest_length)}  #{proto.desc}"]
    lines = [*lines, *yield(proto)] if block_given?
    lines
  end.flatten.join("\n")
end

Instance Method Details

#derivate(**kwargs) ⇒ Object



45
46
47
# File 'lib/dieses/application/sheet.rb', line 45

def derivate(**kwargs)
  self.class.new(name: name, desc: desc, **kwargs).freeze
end

#to_sObject



49
50
51
# File 'lib/dieses/application/sheet.rb', line 49

def to_s
  name.to_s
end