Class: Decode::Language::Ruby::Alias

Inherits:
Definition show all
Defined in:
lib/decode/language/ruby/alias.rb

Overview

Represents an alias statement, e.g., ‘alias new_name old_name` or `alias_method :new_name, :old_name`

Instance Attribute Summary collapse

Attributes inherited from Definition

#The comment lines which directly preceeded the definition., #The language the symbol is defined within., #The path to the definition, relative to the parent., #The source file containing this definition., #comments, #language, #parent, #path, #source, #visibility

Instance Method Summary collapse

Methods inherited from Definition

#:public, :private, :protected=, #The parent definition, defining lexical scope.=, #The symbol name e.g. `:Decode`.=, #container?, #convert, #documentation, #documented?, #full_path, #inspect, #location, #multiline?, #name, #nested?, #nested_name, #public?, #qualified_form, #qualified_name, #start_with?, #text

Constructor Details

#initialize(new_name, old_name, **options) ⇒ Alias

Initialize a new alias definition.



17
18
19
20
# File 'lib/decode/language/ruby/alias.rb', line 17

def initialize(new_name, old_name, **options)
  super(new_name, **options)
  @old_name = old_name
end

Instance Attribute Details

#old_nameObject (readonly)

Returns the value of attribute old_name.



22
23
24
# File 'lib/decode/language/ruby/alias.rb', line 22

def old_name
  @old_name
end

Instance Method Details

#coverage_relevant?Boolean

Aliases don’t require separate documentation as they reference existing methods.



26
27
28
# File 'lib/decode/language/ruby/alias.rb', line 26

def coverage_relevant?
  false
end

#long_formObject

Generate a long form representation of the alias.



36
37
38
# File 'lib/decode/language/ruby/alias.rb', line 36

def long_form
  "alias #{self.name} #{@old_name}"
end

#short_formObject

Generate a short form representation of the alias.



31
32
33
# File 'lib/decode/language/ruby/alias.rb', line 31

def short_form
  "alias #{self.name} #{@old_name}"
end

#to_sObject

Generate a string representation of the alias.



41
42
43
# File 'lib/decode/language/ruby/alias.rb', line 41

def to_s
  "#{self.class.name} #{self.name} -> #{@old_name}"
end