Class: Composer::Package::Link
- Inherits:
-
Object
- Object
- Composer::Package::Link
- Defined in:
- lib/composer/package/link.rb
Overview
Represents a link between two packages, represented by their names
Instance Attribute Summary collapse
-
#constraint ⇒ Object
readonly
Returns the value of attribute constraint.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(source, target, constraint = nil, description = 'relates to', pretty_constraint = nil) ⇒ Link
constructor
Creates a new package link.
- #pretty_constraint ⇒ Object
- #pretty_string(source_package) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(source, target, constraint = nil, description = 'relates to', pretty_constraint = nil) ⇒ Link
Creates a new package link.
26 27 28 29 30 31 32 |
# File 'lib/composer/package/link.rb', line 26 def initialize(source, target, constraint = nil, description = 'relates to', pretty_constraint = nil) @source = source.downcase @target = target.downcase @constraint = constraint @description = description @pretty_constraint = pretty_constraint end |
Instance Attribute Details
#constraint ⇒ Object (readonly)
Returns the value of attribute constraint.
18 19 20 |
# File 'lib/composer/package/link.rb', line 18 def constraint @constraint end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
18 19 20 |
# File 'lib/composer/package/link.rb', line 18 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
18 19 20 |
# File 'lib/composer/package/link.rb', line 18 def target @target end |
Instance Method Details
#pretty_constraint ⇒ Object
34 35 36 37 38 39 |
# File 'lib/composer/package/link.rb', line 34 def pretty_constraint unless @pretty_constraint raise UnexpectedValueError, "Link #{self} has been misconfigured and had no pretty constraint given." end @pretty_constraint end |
#pretty_string(source_package) ⇒ Object
41 42 43 |
# File 'lib/composer/package/link.rb', line 41 def pretty_string(source_package) "#{source_package.pretty_string} #{@description} #{@target} #{@constraint.pretty_string}" end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/composer/package/link.rb', line 45 def to_s "#{@source} #{@description} #{@target} (#{@constraint})" end |