Class: RBI::Parser
Class Method Summary collapse
- .parse_file(path) ⇒ Object
- .parse_files(paths) ⇒ Object
- .parse_string(string) ⇒ Object
- .parse_strings(strings) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse_file(path) ⇒ Object
- #parse_string(string) ⇒ Object
Constructor Details
#initialize ⇒ Parser
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 |