Class: CommentExtractor::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/comment_extractor/extractor.rb,
lib/comment_extractor/extractor/concerns/slash_extractor.rb,
lib/comment_extractor/extractor/concerns/simple_extractor.rb

Defined Under Namespace

Modules: Concerns Classes: C, Cc, Class, Clojure, Coffee, Cpp, Cs, Css, Cxx, D, Erlang, Error, Fortran, Go, H, Haml, Haskell, Hpp, Html, Java, JavaScript, Lisp, Lua, M, Markdown, Mm, Perl, Php, Python, Ruby, Sass, Scala, Scss, Shell, Sqf, Sql, Sqs, SyntaxDefinitionError, Tex, Text, Yaml

Constant Summary collapse

REGEXP =
{
  BREAK: /(?:\r?\n|\r)/,
}.freeze
SCHAME_ACCESSOR_NAMES =
%i[shebang filetype filename]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, code_objects = nil) ⇒ Extractor

Returns a new instance of Extractor.



45
46
47
48
# File 'lib/comment_extractor/extractor.rb', line 45

def initialize(content, code_objects = nil)
  @content = content
  @code_objects = code_objects || CodeObjects.new
end

Instance Attribute Details

#code_objectsObject (readonly)

Returns the value of attribute code_objects.



18
19
20
# File 'lib/comment_extractor/extractor.rb', line 18

def code_objects
  @code_objects
end

#contentObject (readonly)

Returns the value of attribute content.



18
19
20
# File 'lib/comment_extractor/extractor.rb', line 18

def content
  @content
end

Class Method Details

.disable!Object



24
25
26
# File 'lib/comment_extractor/extractor.rb', line 24

def self.disable!
  @status = :disable
end

.disabled?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/comment_extractor/extractor.rb', line 20

def self.disabled?
  @status == :disable
end

.schemaObject



41
42
43
# File 'lib/comment_extractor/extractor.rb', line 41

def self.schema
  @schema ||= {}
end

.schema_accessor(*keys) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/comment_extractor/extractor.rb', line 28

def self.schema_accessor(*keys)
  keys.each do |key|
    define_singleton_method key do |value = nil|
    if value
      self.schema[key] = value
    else
      self.schema[key]
    end
    end
  end
end

Instance Method Details

#extract_commentsObject

#extract_comments should retrun CodeObjects contains instance of CodeObject::Comment



52
53
54
55
56
57
# File 'lib/comment_extractor/extractor.rb', line 52

def extract_comments
  @extracted_comments ||= begin
    scan
    code_objects
  end
end