Class: RbsMiniMagick::Flows::Major5Minor0::ToolInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs_mini_magick/flows/major5_minor0/tool_interface.rb

Overview

RbsMiniMagick::Flows::Major5Minor0::ToolInterface

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ void

Parameters:

  • name (String)


11
12
13
# File 'lib/rbs_mini_magick/flows/major5_minor0/tool_interface.rb', line 11

def initialize(name:)
  @name = name
end

Instance Method Details

#run(state) ⇒ RbsMiniMagick::Flows::State



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rbs_mini_magick/flows/major5_minor0/tool_interface.rb', line 17

def run(state) # rubocop:disable Metrics/MethodLength
  tool_usage = state.fetch_tool_usage(name)
  interface_name = "_#{name.capitalize}"
  option_methods = tool_usage.options
                             .map { option_method(_1) }
                             .uniq.join("\n")
  rbs = <<~RBS
    module MiniMagick
      interface #{interface_name}
        #{option_methods}
      end
    end
  RBS

  state.concat_rbs(rbs)
end