Class: CodeBlockDeterminator
- Inherits:
-
Object
- Object
- CodeBlockDeterminator
- Defined in:
- lib/foucault/code_block_determinator.rb
Overview
Copyright 2014 Huub de Beer
This file is part of Foobar.
Foucault is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Foucault is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Foucault. If not, see <www.gnu.org/licenses/>.
Instance Method Summary collapse
- #collect_line?(line) ⇒ Boolean
-
#initialize ⇒ CodeBlockDeterminator
constructor
A new instance of CodeBlockDeterminator.
Constructor Details
#initialize ⇒ CodeBlockDeterminator
Returns a new instance of CodeBlockDeterminator.
19 20 21 |
# File 'lib/foucault/code_block_determinator.rb', line 19 def initialize() to_start_state end |
Instance Method Details
#collect_line?(line) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/foucault/code_block_determinator.rb', line 23 def collect_line?(line) case @state when :fenced_block if is_fence?(line) and fence_size(line) >= @size and fence_type(line) == @type then # recognized the end of this code block to_start_state else # We're still in a code block: collect this line return true end when :start if is_fence?(line) # Start of a new code block @state = :fenced_block @type = fence_type line @size = fence_size line end end # not in a code block: don't collect this line return false end |