Class: Sbom::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/sbom/output.rb

Constant Summary collapse

VALID_FORMATS =
i[tag json yaml].freeze

Instance Method Summary collapse

Constructor Details

#initialize(filename: nil, format: :tag) ⇒ Output

Returns a new instance of Output.



10
11
12
13
14
# File 'lib/sbom/output.rb', line 10

def initialize(filename: nil, format: :tag)
  @filename = filename
  @format = validate_format(format)
  @output_type = filename && !filename.empty? ? :file : :console
end

Instance Method Details

#formatObject



21
22
23
# File 'lib/sbom/output.rb', line 21

def format
  @format
end

#generate(data) ⇒ Object



16
17
18
19
# File 'lib/sbom/output.rb', line 16

def generate(data)
  formatted = format_data(data)
  send_output(formatted)
end

#output_typeObject



25
26
27
# File 'lib/sbom/output.rb', line 25

def output_type
  @output_type
end