Class: Cease::Eviction::Context
- Inherits:
-
Object
- Object
- Cease::Eviction::Context
- Defined in:
- lib/cease/eviction/context.rb
Instance Attribute Summary collapse
-
#chunk ⇒ Object
readonly
Returns the value of attribute chunk.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(chunk:, comments:, statement:) ⇒ Context
constructor
A new instance of Context.
- #lines ⇒ Object
- #overdue? ⇒ Boolean
Constructor Details
#initialize(chunk:, comments:, statement:) ⇒ Context
Returns a new instance of Context.
58 59 60 61 62 |
# File 'lib/cease/eviction/context.rb', line 58 def initialize(chunk:, comments:, statement:) @chunk = chunk @comments = comments @statement = statement end |
Instance Attribute Details
#chunk ⇒ Object (readonly)
Returns the value of attribute chunk.
90 91 92 |
# File 'lib/cease/eviction/context.rb', line 90 def chunk @chunk end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
90 91 92 |
# File 'lib/cease/eviction/context.rb', line 90 def comments @comments end |
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
90 91 92 |
# File 'lib/cease/eviction/context.rb', line 90 def statement @statement end |
Class Method Details
.from_source(source:) ⇒ Array<Cease::Eviction>
15 16 17 18 19 |
# File 'lib/cease/eviction/context.rb', line 15 def from_source(source:) source_to_chunks(source) do |chunk, statement, comments| new(comments: comments, statement: statement, chunk: chunk) end.compact end |
Instance Method Details
#description ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/cease/eviction/context.rb', line 64 def description indent = ' ' * 2 lines_output = lines.inspect alignment = ' ' * (lines_output.length - indent.length) result = '' header = "#{indent}#{Rainbow(lines_output).blue}: "\ "#{Rainbow(statement.open_comment.past_due_description).indianred}\n" scope.format.each do |line| result << "#{alignment}#{line}\n" end "#{header}#{Rainbow(result).wheat}\n" end |
#lines ⇒ Object
80 81 82 83 |
# File 'lib/cease/eviction/context.rb', line 80 def lines return [] unless statement.valid? statement.lines end |
#overdue? ⇒ Boolean
85 86 87 88 |
# File 'lib/cease/eviction/context.rb', line 85 def overdue? return false unless statement.valid? statement.open_comment.overdue? end |