Class: Toys::Definition::Alias
- Inherits:
-
Object
- Object
- Toys::Definition::Alias
- Defined in:
- lib/toys/definition/alias.rb
Overview
An alias is a name that refers to another name.
Instance Attribute Summary collapse
-
#full_name ⇒ Array<String>
readonly
Return the name of the tool as an array of strings.
-
#priority ⇒ Integer
readonly
Return the priority of this alias.
-
#target_name ⇒ Array<String>
readonly
Return the name of the target as an array of strings.
-
#tool_class ⇒ Class
readonly
Return the tool class.
Instance Method Summary collapse
-
#display_name ⇒ String
Returns a displayable name of this tool, generally the full name delimited by spaces.
-
#display_target ⇒ String
Returns a displayable name of the target, generally the full name delimited by spaces.
-
#initialize(loader, full_name, target, priority) ⇒ Alias
constructor
Create a new alias.
-
#simple_name ⇒ String
Returns the local name of this tool.
Constructor Details
#initialize(loader, full_name, target, priority) ⇒ Alias
Create a new alias.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/toys/definition/alias.rb', line 46 def initialize(loader, full_name, target, priority) @target_name = if target.is_a?(::Array) target.map(&:to_s) else full_name[0..-2] + [target.to_s] end @target_name.freeze @full_name = full_name.map(&:to_s).freeze @priority = priority @tool_class = DSL::Tool.new_class(@full_name, priority, loader) end |
Instance Attribute Details
#full_name ⇒ Array<String> (readonly)
Return the name of the tool as an array of strings. This array may not be modified.
70 71 72 |
# File 'lib/toys/definition/alias.rb', line 70 def full_name @full_name end |
#priority ⇒ Integer (readonly)
Return the priority of this alias.
76 77 78 |
# File 'lib/toys/definition/alias.rb', line 76 def priority @priority end |
#target_name ⇒ Array<String> (readonly)
Return the name of the target as an array of strings. This array may not be modified.
83 84 85 |
# File 'lib/toys/definition/alias.rb', line 83 def target_name @target_name end |
#tool_class ⇒ Class (readonly)
Return the tool class.
63 64 65 |
# File 'lib/toys/definition/alias.rb', line 63 def tool_class @tool_class end |
Instance Method Details
#display_name ⇒ String
Returns a displayable name of this tool, generally the full name delimited by spaces.
98 99 100 |
# File 'lib/toys/definition/alias.rb', line 98 def display_name full_name.join(" ") end |
#display_target ⇒ String
Returns a displayable name of the target, generally the full name delimited by spaces.
107 108 109 |
# File 'lib/toys/definition/alias.rb', line 107 def display_target target_name.join(" ") end |
#simple_name ⇒ String
Returns the local name of this tool.
89 90 91 |
# File 'lib/toys/definition/alias.rb', line 89 def simple_name full_name.last end |