Sha256: cc8cc12c2af1b20d4a884b8b5ecb02d21d13037b28403b8b532e04985926c11e
Contents?: true
Size: 693 Bytes
Versions: 1
Compression:
Stored size: 693 Bytes
Contents
require 'syntax_finder' # Check indentation with `if` and `and`/`or` class IfCondContIndnetFinder < SyntaxFinder def look node if node.type == :if_node inc :if inc :then if node.then_keyword_loc cond = node.predicate case cond.type when :and_node, :or_node inc op: cond.operator_loc.slice d = cond.location.end_line - cond.location.start_line if d > 0 base = node.location.start_column rest_lines = nlines(cond).lines[1..] inc indent: rest_lines.map{|line| /^(\s*)/ =~ line $1.size - base }.min # puts nlines(cond) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
syntax_finder-0.1.0 | samples/if_cond_cont_indent_finder.rb |