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 do |h, k| delim, interpreted = *k delim_pattern = Regexp.escape(delim.dup) # dup: workaround for old Ruby 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 delim_pattern << '\\\\' unless delim == '\\' 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 end
- HEREDOC_PATTERN =
Hash.new do |h, k| delim, interpreted, indented = *k delim_pattern = Regexp.escape(delim.dup) # dup: workaround for old Ruby 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 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.
220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 220 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
170 171 172 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 170 def delim @delim end |
#heredoc ⇒ Object
Returns the value of attribute heredoc
170 171 172 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 170 def heredoc @heredoc end |
#interpreted ⇒ Object
Returns the value of attribute interpreted
170 171 172 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 170 def interpreted @interpreted end |
#next_state ⇒ Object
Returns the value of attribute next_state
170 171 172 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 170 def next_state @next_state end |
#paren ⇒ Object
Returns the value of attribute paren
170 171 172 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 170 def paren @paren end |
#paren_depth ⇒ Object
Returns the value of attribute paren_depth
170 171 172 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 170 def paren_depth @paren_depth end |
#pattern ⇒ Object
Returns the value of attribute pattern
170 171 172 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 170 def pattern @pattern end |
#type ⇒ Object
Returns the value of attribute type
170 171 172 |
# File 'lib/coderay/scanners/ruby/patterns.rb', line 170 def type @type end |