Class: HtmlToHaml::Erb::ControlFlowMatcher
- Inherits:
-
Object
- Object
- HtmlToHaml::Erb::ControlFlowMatcher
- Includes:
- Singleton
- Defined in:
- lib/html_to_haml/tools/erb/control_flow_matcher.rb
Constant Summary collapse
- CONTROL_FLOW_MIDDLE_OF_LINE_KEYWORDS =
["do"]
- CONTROL_FLOW_BEGINNING_OF_LINE_KEYWORDS =
["if", "unless"]
- CONTROL_FLOW_CONTINUE_KEYWORDS =
["elsif", "else", "when"]
Instance Method Summary collapse
- #begin_case_statement?(erb:) ⇒ Boolean
- #begin_indented_control_flow?(erb:) ⇒ Boolean
- #continue_indented_control_flow?(erb:) ⇒ Boolean
- #end_of_block?(erb:) ⇒ Boolean
Instance Method Details
#begin_case_statement?(erb:) ⇒ Boolean
12 13 14 |
# File 'lib/html_to_haml/tools/erb/control_flow_matcher.rb', line 12 def begin_case_statement?(erb:) matches_keywords_at_beginning_of_line?(erb: erb, keywords: ["case"]) end |
#begin_indented_control_flow?(erb:) ⇒ Boolean
16 17 18 19 |
# File 'lib/html_to_haml/tools/erb/control_flow_matcher.rb', line 16 def begin_indented_control_flow?(erb:) matches_keywords?(erb: erb, keywords: CONTROL_FLOW_MIDDLE_OF_LINE_KEYWORDS) || matches_keywords_at_beginning_of_line?(erb: erb, keywords: CONTROL_FLOW_BEGINNING_OF_LINE_KEYWORDS) end |
#continue_indented_control_flow?(erb:) ⇒ Boolean
21 22 23 |
# File 'lib/html_to_haml/tools/erb/control_flow_matcher.rb', line 21 def continue_indented_control_flow?(erb:) matches_keywords_at_beginning_of_line?(erb: erb, keywords: CONTROL_FLOW_CONTINUE_KEYWORDS) end |
#end_of_block?(erb:) ⇒ Boolean
25 26 27 |
# File 'lib/html_to_haml/tools/erb/control_flow_matcher.rb', line 25 def end_of_block?(erb:) erb_without_strings(erb: erb) =~ /\s*-\send/ end |