Class: Spoom::Deadcode::Definition
- Inherits:
-
Object
- Object
- Spoom::Deadcode::Definition
- Defined in:
- lib/spoom/deadcode/definition.rb
Overview
A definition is a class, module, method, constant, etc. being defined in the code
Defined Under Namespace
Instance Attribute Summary collapse
-
#full_name ⇒ Object
readonly
: String.
-
#kind ⇒ Object
readonly
: Kind.
-
#location ⇒ Object
readonly
: Location.
-
#name ⇒ Object
readonly
: String.
-
#status ⇒ Object
readonly
: Status.
Instance Method Summary collapse
-
#alive! ⇒ Object
: -> void.
-
#alive? ⇒ Boolean
: -> bool.
-
#attr_reader? ⇒ Boolean
: -> bool.
-
#attr_writer? ⇒ Boolean
: -> bool.
-
#class? ⇒ Boolean
: -> bool.
-
#constant? ⇒ Boolean
: -> bool.
-
#dead? ⇒ Boolean
: -> bool.
-
#ignored! ⇒ Object
: -> void.
-
#ignored? ⇒ Boolean
: -> bool.
-
#initialize(kind:, name:, full_name:, location:, status: Status::DEAD) ⇒ Definition
constructor
: (kind: Kind, name: String, full_name: String, location: Location, ?status: Status) -> void.
-
#method? ⇒ Boolean
: -> bool.
-
#module? ⇒ Boolean
: -> bool.
-
#to_json(*args) ⇒ Object
: (*untyped args) -> String.
Constructor Details
#initialize(kind:, name:, full_name:, location:, status: Status::DEAD) ⇒ Definition
: (kind: Kind, name: String, full_name: String, location: Location, ?status: Status) -> void
53 54 55 56 57 58 59 |
# File 'lib/spoom/deadcode/definition.rb', line 53 def initialize(kind:, name:, full_name:, location:, status: Status::DEAD) @kind = kind @name = name @full_name = full_name @location = location @status = status end |
Instance Attribute Details
#full_name ⇒ Object (readonly)
: String
44 45 46 |
# File 'lib/spoom/deadcode/definition.rb', line 44 def full_name @full_name end |
#kind ⇒ Object (readonly)
: Kind
38 39 40 |
# File 'lib/spoom/deadcode/definition.rb', line 38 def kind @kind end |
#location ⇒ Object (readonly)
: Location
47 48 49 |
# File 'lib/spoom/deadcode/definition.rb', line 47 def location @location end |
#name ⇒ Object (readonly)
: String
41 42 43 |
# File 'lib/spoom/deadcode/definition.rb', line 41 def name @name end |
#status ⇒ Object (readonly)
: Status
50 51 52 |
# File 'lib/spoom/deadcode/definition.rb', line 50 def status @status end |
Instance Method Details
#alive! ⇒ Object
: -> void
101 102 103 |
# File 'lib/spoom/deadcode/definition.rb', line 101 def alive! @status = Status::ALIVE end |
#alive? ⇒ Boolean
: -> bool
96 97 98 |
# File 'lib/spoom/deadcode/definition.rb', line 96 def alive? status == Status::ALIVE end |
#attr_reader? ⇒ Boolean
: -> bool
64 65 66 |
# File 'lib/spoom/deadcode/definition.rb', line 64 def attr_reader? kind == Kind::AttrReader end |
#attr_writer? ⇒ Boolean
: -> bool
69 70 71 |
# File 'lib/spoom/deadcode/definition.rb', line 69 def attr_writer? kind == Kind::AttrWriter end |
#class? ⇒ Boolean
: -> bool
74 75 76 |
# File 'lib/spoom/deadcode/definition.rb', line 74 def class? kind == Kind::Class end |
#constant? ⇒ Boolean
: -> bool
79 80 81 |
# File 'lib/spoom/deadcode/definition.rb', line 79 def constant? kind == Kind::Constant end |
#dead? ⇒ Boolean
: -> bool
106 107 108 |
# File 'lib/spoom/deadcode/definition.rb', line 106 def dead? status == Status::DEAD end |
#ignored! ⇒ Object
: -> void
116 117 118 |
# File 'lib/spoom/deadcode/definition.rb', line 116 def ignored! @status = Status::IGNORED end |
#ignored? ⇒ Boolean
: -> bool
111 112 113 |
# File 'lib/spoom/deadcode/definition.rb', line 111 def ignored? status == Status::IGNORED end |
#method? ⇒ Boolean
: -> bool
84 85 86 |
# File 'lib/spoom/deadcode/definition.rb', line 84 def method? kind == Kind::Method end |
#module? ⇒ Boolean
: -> bool
89 90 91 |
# File 'lib/spoom/deadcode/definition.rb', line 89 def module? kind == Kind::Module end |
#to_json(*args) ⇒ Object
: (*untyped args) -> String
123 124 125 126 127 128 129 |
# File 'lib/spoom/deadcode/definition.rb', line 123 def to_json(*args) { kind: kind, name: name, location: location.to_s, }.to_json end |