Class: SublimeSyntaxConvertor::BeginEndPattern

Inherits:
Object
  • Object
show all
Includes:
Formatter
Defined in:
lib/sublime_syntax_convertor/patterns.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Formatter

#format_captures, #format_comment, #format_external_syntax, #format_regex, #leading_whitespace, #needs_quoting?, #quote

Constructor Details

#initialize(type, pattern) ⇒ BeginEndPattern

Returns a new instance of BeginEndPattern.



29
30
31
32
33
34
35
# 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

Instance Attribute Details

#capturesObject (readonly)

Returns the value of attribute captures.



27
28
29
# File 'lib/sublime_syntax_convertor/patterns.rb', line 27

def captures
  @captures
end

#matchObject (readonly)

Returns the value of attribute match.



27
28
29
# File 'lib/sublime_syntax_convertor/patterns.rb', line 27

def match
  @match
end

#popObject (readonly)

Returns the value of attribute pop.



27
28
29
# File 'lib/sublime_syntax_convertor/patterns.rb', line 27

def pop
  @pop
end

Instance Method Details

#to_hObject



37
38
39
40
41
42
43
# 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