Class: RBI::Parser

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

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse_file(path) ⇒ Object



25
26
27
# File 'lib/rbi/parser.rb', line 25

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

.parse_string(string) ⇒ Object



20
21
22
# File 'lib/rbi/parser.rb', line 20

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

Instance Method Details

#parse_file(path) ⇒ Object



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

def parse_file(path)
  parse(::File.read(path), file: path)
rescue ::Parser::SyntaxError => e
  raise Error, e.message
end

#parse_string(string) ⇒ Object



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

def parse_string(string)
  parse(string, file: "-")
rescue ::Parser::SyntaxError => e
  raise Error, e.message
end