Class: Parlour::RbiGenerator::Options
- Inherits:
-
Object
- Object
- Parlour::RbiGenerator::Options
- Extended by:
- T::Sig
- Defined in:
- lib/parlour/rbi_generator/options.rb
Overview
A set of immutable formatting options passed to all calls of RbiObject#generate_rbi.
Instance Attribute Summary collapse
-
#break_params ⇒ Integer
readonly
If there are at least this many parameters in a Sorbet
sig
, then it is broken onto separate lines. -
#tab_size ⇒ Integer
readonly
The number of spaces to use per indent.
Instance Method Summary collapse
-
#indented(level, str) ⇒ String
Returns a string indented to the given indent level, according to the set #tab_size.
-
#initialize(break_params:, tab_size:) ⇒ void
constructor
Creates a new set of formatting options.
Constructor Details
#initialize(break_params:, tab_size:) ⇒ void
Creates a new set of formatting options.
19 20 21 22 |
# File 'lib/parlour/rbi_generator/options.rb', line 19 def initialize(break_params:, tab_size:) @break_params = break_params @tab_size = tab_size end |
Instance Attribute Details
#break_params ⇒ Integer (readonly)
If there are at least this many parameters in a Sorbet sig
, then it is broken onto separate lines.
# With break_params: 5
sig { params(name: String, age: Integer, hobbies: T::Array(String), country: Symbol).void }
# With break_params: 4
sig do
params(
name: String,
age: Integer,
hobbies: T::Array(String),
country: Symbol
).void
end
42 43 44 |
# File 'lib/parlour/rbi_generator/options.rb', line 42 def break_params @break_params end |
#tab_size ⇒ Integer (readonly)
The number of spaces to use per indent.
47 48 49 |
# File 'lib/parlour/rbi_generator/options.rb', line 47 def tab_size @tab_size end |
Instance Method Details
#indented(level, str) ⇒ String
Returns a string indented to the given indent level, according to the set #tab_size.
56 57 58 |
# File 'lib/parlour/rbi_generator/options.rb', line 56 def indented(level, str) " " * (level * tab_size) + str end |