Class: Sbom::Output
- Inherits:
-
Object
- Object
- Sbom::Output
- Defined in:
- lib/sbom/output.rb
Constant Summary collapse
- VALID_FORMATS =
i[tag json yaml].freeze
Instance Method Summary collapse
- #format ⇒ Object
- #generate(data) ⇒ Object
-
#initialize(filename: nil, format: :tag) ⇒ Output
constructor
A new instance of Output.
- #output_type ⇒ Object
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
#format ⇒ Object
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_type ⇒ Object
25 26 27 |
# File 'lib/sbom/output.rb', line 25 def output_type @output_type end |