Module: Cecil::Indentation::Ambiguity
- Defined in:
- lib/cecil/indentation.rb
Class Method Summary collapse
-
.adjust_by(adjustment) ⇒ Object
When given an ambiguously indented string, it assumes that first line is
adjustmentcharacters less than the least indented of the other lines. -
.ignore ⇒ Object
When given an ambiguously indented string, assume that first line is the same as the least indented of the other lines.
-
.raise_error ⇒ Object
When given an ambiguously indented string, raise an exception.
Class Method Details
.adjust_by(adjustment) ⇒ Object
When given an ambiguously indented string, it assumes that first line is adjustment characters less than the
least indented of the other lines.
Useful for this situation. Setting to adjust_by(4) will behave
according to what's intended.
`def python_fn():
pass`
25 |
# File 'lib/cecil/indentation.rb', line 25 def adjust_by(adjustment) = ->(min_level:, **) { min_level - adjustment } |
.ignore ⇒ Object
When given an ambiguously indented string, assume that first line is the same as the least indented of the other lines.
Useful for this situation:
`def ruby_method
end`
34 |
# File 'lib/cecil/indentation.rb', line 34 def ignore = adjust_by(0) |
.raise_error ⇒ Object
When given an ambiguously indented string, raise an exception
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cecil/indentation.rb', line 37 def raise_error lambda do |src:, **| raise " Indentation is ambiguous, cannot reindent. Try adding a blank\n line at the beginning or end of this fragment. Fragment:\n\n \#{src}\n MSG\n end\nend\n" |