Class: RBI::Parser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/rbi/parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



31
32
33
34
# File 'lib/rbi/parser.rb', line 31

def initialize
  # Delay load unparser and only if it has not been loaded already.
  require "unparser" unless defined?(::Unparser)
end

Class Method Details

.parse_file(path) ⇒ Object



42
43
44
# File 'lib/rbi/parser.rb', line 42

def self.parse_file(path)
  Parser.new.parse_file(path)
end

.parse_files(paths) ⇒ Object



47
48
49
50
# File 'lib/rbi/parser.rb', line 47

def self.parse_files(paths)
  parser = Parser.new
  paths.map { |path| parser.parse_file(path) }
end

.parse_string(string) ⇒ Object



37
38
39
# File 'lib/rbi/parser.rb', line 37

def self.parse_string(string)
  Parser.new.parse_string(string)
end

.parse_strings(strings) ⇒ Object



58
59
60
61
# File 'lib/rbi/parser.rb', line 58

def self.parse_strings(strings)
  parser = Parser.new
  strings.map { |string| parser.parse_string(string) }
end

Instance Method Details

#parse_file(path) ⇒ Object



64
65
66
# File 'lib/rbi/parser.rb', line 64

def parse_file(path)
  parse(::File.read(path), file: path)
end

#parse_string(string) ⇒ Object



53
54
55
# File 'lib/rbi/parser.rb', line 53

def parse_string(string)
  parse(string, file: "-")
end