Class: SublimeSyntaxConvertor::MatchPattern
- Inherits:
-
Object
- Object
- SublimeSyntaxConvertor::MatchPattern
- Includes:
- Formatter
- Defined in:
- lib/sublime_syntax_convertor/patterns.rb
Instance Attribute Summary collapse
-
#captures ⇒ Object
readonly
Returns the value of attribute captures.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(pat) ⇒ MatchPattern
constructor
A new instance of MatchPattern.
- #to_h ⇒ Object
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
#captures ⇒ Object (readonly)
Returns the value of attribute captures.
6 7 8 |
# File 'lib/sublime_syntax_convertor/patterns.rb', line 6 def captures @captures end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
6 7 8 |
# File 'lib/sublime_syntax_convertor/patterns.rb', line 6 def comment @comment end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
6 7 8 |
# File 'lib/sublime_syntax_convertor/patterns.rb', line 6 def match @match end |
#scope ⇒ Object (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_h ⇒ Object
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 |