Class: SublimeSyntaxConvertor::MatchPattern

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(pat) ⇒ MatchPattern

Returns a new instance of MatchPattern.



8
9
10
11
12
13
# File 'lib/sublime_syntax_convertor/patterns.rb', line 8

def initialize(pat)
  @match = format_regex(pat['match'])
  @scope = pat['name'] if pat.key?('name')
  @captures = format_captures(pat['captures']) if pat.key?('captures')
  @comment = format_comment(pat['comment']) if pat.key?('comment') && !format_comment(pat['comment']).empty?
end

Instance Attribute Details

#capturesObject (readonly)

Returns the value of attribute captures.



6
7
8
# File 'lib/sublime_syntax_convertor/patterns.rb', line 6

def captures
  @captures
end

#commentObject (readonly)

Returns the value of attribute comment.



6
7
8
# File 'lib/sublime_syntax_convertor/patterns.rb', line 6

def comment
  @comment
end

#matchObject (readonly)

Returns the value of attribute match.



6
7
8
# File 'lib/sublime_syntax_convertor/patterns.rb', line 6

def match
  @match
end

#scopeObject (readonly)

Returns the value of attribute scope.



6
7
8
# File 'lib/sublime_syntax_convertor/patterns.rb', line 6

def scope
  @scope
end

Instance Method Details

#to_hObject



15
16
17
18
19
20
21
22
# File 'lib/sublime_syntax_convertor/patterns.rb', line 15

def to_h
  hash = {}
  hash['match'] = @match if @match
  hash['scope'] = @scope if @scope
  hash['captures'] = @captures if @captures
  hash['comment'] = @comment if @comment
  hash
end