Class: Spoom::Model::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/spoom/model/reference.rb

Overview

A reference to something that looks like a constant or a method

Constants could be classes, modules, or actual constants. Methods could be accessors, instance or class methods, aliases, etc.

Defined Under Namespace

Classes: Kind

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, name:, location:) ⇒ Reference

: (kind: Kind, name: String, location: Spoom::Location) -> void



48
49
50
51
52
# File 'lib/spoom/model/reference.rb', line 48

def initialize(kind:, name:, location:)
  @kind = kind
  @name = name
  @location = location
end

Instance Attribute Details

#kind ⇒ Object (readonly)

: Kind



39
40
41
# File 'lib/spoom/model/reference.rb', line 39

def kind
  @kind
end

#location ⇒ Object (readonly)

: Spoom::Location



45
46
47
# File 'lib/spoom/model/reference.rb', line 45

def location
  @location
end

#name ⇒ Object (readonly)

: String



42
43
44
# File 'lib/spoom/model/reference.rb', line 42

def name
  @name
end

Class Method Details

.constant(name, location) ⇒ Object

: (String name, Spoom::Location location) -> Reference



28
29
30
# File 'lib/spoom/model/reference.rb', line 28

def constant(name, location)
  new(name: name, kind: Kind::Constant, location: location)
end

.method(name, location) ⇒ Object

: (String name, Spoom::Location location) -> Reference



33
34
35
# File 'lib/spoom/model/reference.rb', line 33

def method(name, location)
  new(name: name, kind: Kind::Method, location: location)
end

Instance Method Details

#constant? ⇒ Boolean

: -> bool

Returns:

  • (Boolean)


55
56
57
# File 'lib/spoom/model/reference.rb', line 55

def constant?
  kind == Kind::Constant
end

#method? ⇒ Boolean

: -> bool

Returns:

  • (Boolean)


60
61
62
# File 'lib/spoom/model/reference.rb', line 60

def method?
  kind == Kind::Method
end