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

#alias?Boolean

Whether this definition represents an alias.

Returns:

  • (Boolean)


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

def alias?
	true
end

#aliased_nameObject

The original name this alias refers to.



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

def aliased_name
	@old_name
end

#coverage_relevant?Boolean

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

Returns:

  • (Boolean)


38
39
40
# File 'lib/decode/language/ruby/alias.rb', line 38

def coverage_relevant?
	false
end

#long_formObject

Generate a long form representation of the alias.



48
49
50
# File 'lib/decode/language/ruby/alias.rb', line 48

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

#short_formObject

Generate a short form representation of the alias.



43
44
45
# File 'lib/decode/language/ruby/alias.rb', line 43

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

#to_sObject

Generate a string representation of the alias.



53
54
55
# File 'lib/decode/language/ruby/alias.rb', line 53

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