Class: Elisp2any::HeaderLine

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename:, description:, variables:) ⇒ HeaderLine

Returns a new instance of HeaderLine.



74
75
76
77
78
# File 'lib/elisp2any/header_line.rb', line 74

def initialize(filename:, description:, variables:)
  @filename = filename
  @description = description
  @variables = variables
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/elisp2any/header_line.rb', line 6

def description
  @description
end

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/elisp2any/header_line.rb', line 6

def filename
  @filename
end

#variablesObject (readonly)

Returns the value of attribute variables.



6
7
8
# File 'lib/elisp2any/header_line.rb', line 6

def variables
  @variables
end

Class Method Details

.scan(scanner) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/elisp2any/header_line.rb', line 8

def self.scan(scanner)
  scanner = StringScanner.new(scanner) unless scanner.respond_to?(:pos)
  pos = scanner.pos
  unless (heading = Elisp2any.scan_top_heading(scanner))
    scanner.pos = pos
    return
  end
  cscanner = StringScanner.new(heading)
  unless (filename = Elisp2any.scan_filename(cscanner))
    scanner.pos = pos
    return
  end
  unless cscanner.skip(/ +--- +/)
    scanner.pos = pos
    return
  end
  description = +""
  variables = nil
  until cscanner.eos?
    if (variables = scan_variables(cscanner)) # nop
      break
    else
      description << cscanner.getch
    end
  end
  if description.empty?
    scanner.pos = pos
    return
  end
  new(filename:, description:, variables:)
end