Class: TaskListToggleService
- Inherits:
-
Object
- Object
- TaskListToggleService
- Defined in:
- app/services/task_list_toggle_service.rb
Overview
Finds the correct checkbox in the passed in markdown/html and toggles it’s state, returning the updated markdown/html. We don’t care if the text has changed above or below the specific checkbox, as long the checkbox still exists at exactly the same line number and the text is equal. If successful, new values are available in ‘updated_markdown` and `updated_markdown_html`
Instance Attribute Summary collapse
-
#updated_markdown ⇒ Object
readonly
Returns the value of attribute updated_markdown.
-
#updated_markdown_html ⇒ Object
readonly
Returns the value of attribute updated_markdown_html.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(markdown, markdown_html, line_source:, line_number:, toggle_as_checked:) ⇒ TaskListToggleService
constructor
A new instance of TaskListToggleService.
Constructor Details
#initialize(markdown, markdown_html, line_source:, line_number:, toggle_as_checked:) ⇒ TaskListToggleService
Returns a new instance of TaskListToggleService.
11 12 13 14 15 16 17 18 19 |
# File 'app/services/task_list_toggle_service.rb', line 11 def initialize(markdown, markdown_html, line_source:, line_number:, toggle_as_checked:) @markdown = markdown @markdown_html = markdown_html @line_source = line_source @line_number = line_number @toggle_as_checked = toggle_as_checked @updated_markdown, @updated_markdown_html = nil end |
Instance Attribute Details
#updated_markdown ⇒ Object (readonly)
Returns the value of attribute updated_markdown.
9 10 11 |
# File 'app/services/task_list_toggle_service.rb', line 9 def updated_markdown @updated_markdown end |
#updated_markdown_html ⇒ Object (readonly)
Returns the value of attribute updated_markdown_html.
9 10 11 |
# File 'app/services/task_list_toggle_service.rb', line 9 def updated_markdown_html @updated_markdown_html end |
Instance Method Details
#execute ⇒ Object
21 22 23 24 25 |
# File 'app/services/task_list_toggle_service.rb', line 21 def execute return false unless markdown && markdown_html toggle_markdown && toggle_markdown_html end |