Class: Leftovers::DefinitionToAdd
- Inherits:
-
Object
- Object
- Leftovers::DefinitionToAdd
- Defined in:
- lib/leftovers/definition_to_add.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(node, name: node.name, location: node.loc.name) ⇒ DefinitionToAdd
constructor
A new instance of DefinitionToAdd.
- #keep?(file_collector) ⇒ Boolean
- #privacy=(value) ⇒ Object
- #test?(file_collector) ⇒ Boolean
- #to_definition(file_collector) ⇒ Object
Constructor Details
#initialize(node, name: node.name, location: node.loc.name) ⇒ DefinitionToAdd
Returns a new instance of DefinitionToAdd.
7 8 9 10 11 |
# File 'lib/leftovers/definition_to_add.rb', line 7 def initialize(node, name: node.name, location: node.loc.name) @node = node @name = name @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/leftovers/definition_to_add.rb', line 5 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/leftovers/definition_to_add.rb', line 5 def name @name end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
5 6 7 |
# File 'lib/leftovers/definition_to_add.rb', line 5 def node @node end |
Instance Method Details
#keep?(file_collector) ⇒ Boolean
17 18 19 |
# File 'lib/leftovers/definition_to_add.rb', line 17 def keep?(file_collector) @keep ||= file_collector.keep_line?(location.line) || ::Leftovers.config.keep === node end |
#privacy=(value) ⇒ Object
13 14 15 |
# File 'lib/leftovers/definition_to_add.rb', line 13 def privacy=(value) @node.privacy = value end |
#test?(file_collector) ⇒ Boolean
21 22 23 |
# File 'lib/leftovers/definition_to_add.rb', line 21 def test?(file_collector) file_collector.test_line?(location.line) || ::Leftovers.config.test_only === node end |
#to_definition(file_collector) ⇒ Object
25 26 27 28 29 |
# File 'lib/leftovers/definition_to_add.rb', line 25 def to_definition(file_collector) return if keep?(file_collector) Definition.new(name, location: location, test: test?(file_collector)) end |