class SublimeSyntaxConvertor::BeginEndPattern

Attributes

captures[R]
match[R]
pop[R]

Public Class Methods

new(type, pattern) click to toggle source
# File lib/sublime_syntax_convertor/patterns.rb, line 29
def initialize(type, pattern)
  @pattern = pattern
  @type = type
  @match = format_regex(pattern[type])
  @pop = true if type == 'end'
  handle_captures
end

Public Instance Methods

to_h() click to toggle source
# File lib/sublime_syntax_convertor/patterns.rb, line 37
def to_h
  hash = {}
  hash['match'] = @match if @match
  hash['pop'] = @pop if @pop
  hash['captures'] = @captures if @captures
  hash
end

Private Instance Methods

handle_captures() click to toggle source
# File lib/sublime_syntax_convertor/patterns.rb, line 47
def handle_captures
  pattern_captures = @pattern["#{@type}Captures"] || @pattern["captures"]
  return unless pattern_captures
  captures = format_captures(pattern_captures)
  if captures.key?('0')
    entry['scope'] = captures['0']
    captures.delete('0')
  end
  @captures = captures if captures.size > 0
end