Class: Bashly::Script::Dependency
- Inherits:
-
Object
- Object
- Bashly::Script::Dependency
- Defined in:
- lib/bashly/script/dependency.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(label: nil, commands: nil, help: nil) ⇒ Dependency
constructor
A new instance of Dependency.
- #multi? ⇒ Boolean
- #name ⇒ Object
Constructor Details
#initialize(label: nil, commands: nil, help: nil) ⇒ Dependency
Returns a new instance of Dependency.
27 28 29 30 31 |
# File 'lib/bashly/script/dependency.rb', line 27 def initialize(label: nil, commands: nil, help: nil) @label = label @commands = commands.is_a?(String) ? [commands] : commands @help = help&.empty? ? nil : help end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
4 5 6 |
# File 'lib/bashly/script/dependency.rb', line 4 def commands @commands end |
#help ⇒ Object (readonly)
Returns the value of attribute help.
4 5 6 |
# File 'lib/bashly/script/dependency.rb', line 4 def help @help end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'lib/bashly/script/dependency.rb', line 4 def label @label end |
Class Method Details
.from_config(key, value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bashly/script/dependency.rb', line 11 def from_config(key, value) = case value when nil { label: key, commands: key } when String { label: key, commands: key, help: value } when Hash { label: key, commands: value['command'], help: value['help'] } else {} end new(**) end |
.option_keys ⇒ Object
7 8 9 |
# File 'lib/bashly/script/dependency.rb', line 7 def option_keys @option_keys ||= %i[command help] end |
Instance Method Details
#multi? ⇒ Boolean
33 34 35 |
# File 'lib/bashly/script/dependency.rb', line 33 def multi? @multi ||= commands.size > 1 end |
#name ⇒ Object
37 38 39 |
# File 'lib/bashly/script/dependency.rb', line 37 def name @name ||= multi? ? "#{label} (#{commands.join '/'})" : label end |