Class: CodeRay::Scanners::Ruby::Patterns::StringState
- Inherits:
-
Struct
- Object
- Struct
- CodeRay::Scanners::Ruby::Patterns::StringState
- Defined in:
- lib/coderay/scanners/ruby/patterns.rb
Constant Summary collapse
- CLOSING_PAREN =
- OPENING_PAREN =
CLOSING_PAREN.invert
- STRING_PATTERN =
Hash.new { |h, k| delim, interpreted = *k delim_pattern = Regexp.escape(delim) if closing_paren = CLOSING_PAREN[delim] delim_pattern = delim_pattern[0..-1] if defined? JRUBY_VERSION # JRuby fix delim_pattern << Regexp.escape(closing_paren) end special_escapes = case interpreted when :regexp_symbols '| ' + REGEXP_SYMBOLS.source when :words '| \s' end h[k] = if interpreted and not delim == '#' / (?= [#{delim_pattern}\\] | \# [{$@] #{special_escapes} ) /mx else / (?= [#{delim_pattern}\\] #{special_escapes} ) /mx end }
- HEREDOC_PATTERN =
Hash.new { |h, k| delim, interpreted, indented = *k delim_pattern = Regexp.escape(delim.dup) delim_pattern = / \n #{ '(?>[\ \t]*)' if indented } #{ Regexp.new delim_pattern } $ /x h[k] = if interpreted / (?= #{delim_pattern}() | \\ | \# [{$@] ) /mx # $1 set == end of heredoc else / (?= #{delim_pattern}() | \\ ) /mx end }
Instance Attribute Summary collapse
-
#delim ⇒ Object
Returns the value of attribute delim.
-
#heredoc ⇒ Object
Returns the value of attribute heredoc.
-
#interpreted ⇒ Object
Returns the value of attribute interpreted.
-
#next_state ⇒ Object
Returns the value of attribute next_state.
-
#paren ⇒ Object
Returns the value of attribute paren.
-
#paren_depth ⇒ Object
Returns the value of attribute paren_depth.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(kind, interpreted, delim, heredoc = false) ⇒ StringState
constructor
A new instance of StringState.
Constructor Details
#initialize(kind, interpreted, delim, heredoc = false) ⇒ StringState
Returns a new instance of StringState.
214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 214 def initialize kind, interpreted, delim, heredoc = false if heredoc pattern = HEREDOC_PATTERN[ [delim, interpreted, heredoc == :indented] ] delim = nil else pattern = STRING_PATTERN[ [delim, interpreted] ] if paren = CLOSING_PAREN[delim] delim, paren = paren, delim paren_depth = 1 end end super kind, interpreted, delim, heredoc, paren, paren_depth, pattern, :initial end |
Instance Attribute Details
#delim ⇒ Object
Returns the value of attribute delim
164 165 166 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 164 def delim @delim end |
#heredoc ⇒ Object
Returns the value of attribute heredoc
164 165 166 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 164 def heredoc @heredoc end |
#interpreted ⇒ Object
Returns the value of attribute interpreted
164 165 166 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 164 def interpreted @interpreted end |
#next_state ⇒ Object
Returns the value of attribute next_state
164 165 166 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 164 def next_state @next_state end |
#paren ⇒ Object
Returns the value of attribute paren
164 165 166 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 164 def paren @paren end |
#paren_depth ⇒ Object
Returns the value of attribute paren_depth
164 165 166 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 164 def paren_depth @paren_depth end |
#pattern ⇒ Object
Returns the value of attribute pattern
164 165 166 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 164 def pattern @pattern end |
#type ⇒ Object
Returns the value of attribute type
164 165 166 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 164 def type @type end |