Class: Starter::Importer::Description

Inherits:
Object
  • Object
show all
Defined in:
lib/starter/importer/description.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:) ⇒ Description

Returns a new instance of Description.



8
9
10
# File 'lib/starter/importer/description.rb', line 8

def initialize(content:)
  @content = content
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/starter/importer/description.rb', line 6

def content
  @content
end

Instance Method Details

#block_keysObject



28
29
30
31
32
33
# File 'lib/starter/importer/description.rb', line 28

def block_keys
  %w[
    description
    tags
  ]
end

#to_sObject

rubocop:disable Metrics/AbcSize



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/starter/importer/description.rb', line 12

def to_s # rubocop:disable Metrics/AbcSize
  return if content.blank?

  desc = content['summary'] || content['operationId']
  entry = "desc '#{desc}'\n"

  return entry unless block_keys.intersect?(content.keys)

  entry.sub!("\n", " do\n")
  entry << "  detail '#{content['description']}'\n" if content.key?('description')
  entry << "  tags #{content['tags']}\n" if content.key?('tags')
  entry << 'end'

  entry
end