Class: LibRubyParser::MagicComment

Inherits:
Object
  • Object
show all
Defined in:
lib/lib-ruby-parser.rb

Overview

Representation of a magic comment in Ruby

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, key_l:, value_l:) ⇒ MagicComment

Returns a new instance of MagicComment.

Parameters:

  • kind (Symbol)
  • key_l (Loc)
  • value_l (Loc)


151
152
153
154
155
# File 'lib/lib-ruby-parser.rb', line 151

def initialize(kind:, key_l:, value_l:)
  @kind = kind
  @key_l = key_l
  @value_l = value_l
end

Instance Attribute Details

#key_lLoc

Location of the “key”

Examples:

# encoding: utf-8
  ~~~~~~~~

Returns:



137
138
139
# File 'lib/lib-ruby-parser.rb', line 137

def key_l
  @key_l
end

#kindSymbol

Kind of a magic comment, can be

  1. +encoding+
  2. +frozen_string_literal+
  3. +warn_indent+
  4. +shareable_constant_value+

Returns:

  • (Symbol)


128
129
130
# File 'lib/lib-ruby-parser.rb', line 128

def kind
  @kind
end

#value_lLoc

Location of the “value”

Examples:

# encoding: utf-8
            ~~~~~

Returns:



146
147
148
# File 'lib/lib-ruby-parser.rb', line 146

def value_l
  @value_l
end