Class: SecurityTxt::Generator
- Inherits:
-
Object
- Object
- SecurityTxt::Generator
- Defined in:
- lib/securitytxt/generator.rb
Overview
Generator of Security.txt
Instance Attribute Summary collapse
-
#sections ⇒ Object
Returns the value of attribute sections.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(data = {}) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(data = {}) ⇒ Generator
Returns a new instance of Generator.
5 6 7 |
# File 'lib/securitytxt/generator.rb', line 5 def initialize(data = {}) @sections = data end |
Instance Attribute Details
#sections ⇒ Object
Returns the value of attribute sections.
4 5 6 |
# File 'lib/securitytxt/generator.rb', line 4 def sections @sections end |
Instance Method Details
#generate ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/securitytxt/generator.rb', line 9 def generate ret = StringIO.new sections.each do |name, value| next if value.nil? || value.empty? if value.is_a?(Array) value.each { |subvalue| ret << "#{capitalize(name)}: #{subvalue}\n" } else ret << "#{capitalize(name)}: #{value}\n" end end ret.string end |