Class: RbsInlineData::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs_inline_data/writer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definitions) ⇒ Writer

(Array) -> void



13
14
15
# File 'lib/rbs_inline_data/writer.rb', line 13

def initialize(definitions)
  @definitions = definitions
end

Class Method Details

.write(definitions, output_path) ⇒ Object

(Array, Pathname?) -> void



6
7
8
# File 'lib/rbs_inline_data/writer.rb', line 6

def self.write(definitions, output_path)
  new(definitions).write(output_path)
end

Instance Method Details

#write(output_path) ⇒ Object

(Pathname?) -> void



18
19
20
21
22
23
24
25
26
27
# File 'lib/rbs_inline_data/writer.rb', line 18

def write(output_path)
  return if @definitions.empty?

  if output_path
    output_path.parent.mkpath unless output_path.parent.directory?
    output_path.write(build_rbs(@definitions))
  else
    puts build_rbs(@definitions)
  end
end