Class: Cease::Eviction::Statement
- Inherits:
-
Object
- Object
- Cease::Eviction::Statement
- Defined in:
- lib/cease/eviction/statement.rb
Instance Attribute Summary collapse
-
#close_comment ⇒ Object
readonly
Returns the value of attribute close_comment.
-
#open_comment ⇒ Object
readonly
Returns the value of attribute open_comment.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(open_comment:, close_comment:, source:) ⇒ Statement
constructor
A new instance of Statement.
- #lines ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(open_comment:, close_comment:, source:) ⇒ Statement
Returns a new instance of Statement.
19 20 21 22 |
# File 'lib/cease/eviction/statement.rb', line 19 def initialize(open_comment:, close_comment:, source:) @open_comment = Comment.new(comment: open_comment, source: source) @close_comment = Comment.new(comment: close_comment, source: source) end |
Instance Attribute Details
#close_comment ⇒ Object (readonly)
Returns the value of attribute close_comment.
36 37 38 |
# File 'lib/cease/eviction/statement.rb', line 36 def close_comment @close_comment end |
#open_comment ⇒ Object (readonly)
Returns the value of attribute open_comment.
36 37 38 |
# File 'lib/cease/eviction/statement.rb', line 36 def open_comment @open_comment end |
Class Method Details
.from_comments(*comments) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/cease/eviction/statement.rb', line 6 def self.from_comments(*comments) open_comment, close_comment, source = comments new( open_comment: open_comment, close_comment: close_comment, source: source ) end |
Instance Method Details
#lines ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/cease/eviction/statement.rb', line 24 def lines return [] unless valid? [open_comment, close_comment].map do |eviction_comment| eviction_comment.loc&.line end end |
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/cease/eviction/statement.rb', line 32 def valid? [open_comment, close_comment].all?(&:valid?) end |