Class: Elisp2any::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/elisp2any/comment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(colons:, content:, padding:) ⇒ Comment



13
14
15
16
17
# File 'lib/elisp2any/comment.rb', line 13

def initialize(colons:, content:, padding:)
  @colons = colons
  @content = content
  @padding = padding
end

Instance Attribute Details

#colonsObject (readonly)

Returns the value of attribute colons.



3
4
5
# File 'lib/elisp2any/comment.rb', line 3

def colons
  @colons
end

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/elisp2any/comment.rb', line 3

def content
  @content
end

#paddingObject (readonly)

Returns the value of attribute padding.



3
4
5
# File 'lib/elisp2any/comment.rb', line 3

def padding
  @padding
end

Class Method Details

.scan(scanner) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/elisp2any/comment.rb', line 5

def self.scan(scanner)
  scanner = StringScanner.new(scanner) unless scanner.respond_to?(:skip)
  scanner.skip(/(?<colons>;+)(?<padding> *)(?<content>.*)\n?/) or return
  new(colons: scanner[:colons].size,
      content: scanner[:content],
      padding: scanner[:padding])
end