Method: Parser::Source::Comment#type

Defined in:
lib/parser/source/comment.rb

#typeSymbol

Type of this comment.

* Inline comments correspond to `:inline`:

      # whatever

* Block comments correspond to `:document`:

      =begin
      hi i am a document
      =end

Returns:

  • (Symbol)
[View source]

89
90
91
92
93
94
95
# File 'lib/parser/source/comment.rb', line 89

def type
  if text.start_with?("#".freeze)
    :inline
  elsif text.start_with?("=begin".freeze)
    :document
  end
end