Class: Bibliothecary::ParserResult

Inherits:
Object
  • Object
show all
Defined in:
lib/bibliothecary/parser_result.rb

Overview

ParserResult bundles together a list of dependencies and the project name.

Constant Summary collapse

FIELDS =
i[
  dependencies
  project_name
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependencies:, project_name: nil) ⇒ ParserResult



16
17
18
19
20
21
22
# File 'lib/bibliothecary/parser_result.rb', line 16

def initialize(
  dependencies:,
  project_name: nil
)
  @dependencies = dependencies
  @project_name = project_name
end

Instance Attribute Details

#dependenciesArray<Dependency> (readonly)

The list of Dependency objects



8
9
10
# File 'lib/bibliothecary/parser_result.rb', line 8

def dependencies
  @dependencies
end

#project_nameString? (readonly)

The name of the project



8
9
10
# File 'lib/bibliothecary/parser_result.rb', line 8

def project_name
  @project_name
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==



24
25
26
# File 'lib/bibliothecary/parser_result.rb', line 24

def eql?(other)
  FIELDS.all? { |f| public_send(f) == other.public_send(f) }
end

#hashObject



33
34
35
# File 'lib/bibliothecary/parser_result.rb', line 33

def hash
  FIELDS.map { |f| public_send(f) }.hash
end

#to_hObject



29
30
31
# File 'lib/bibliothecary/parser_result.rb', line 29

def to_h
  FIELDS.to_h { |f| [f, public_send(f)] }
end