Class: Parlour::Options
- Inherits:
-
Object
- Object
- Parlour::Options
- Extended by:
- T::Sig
- Defined in:
- lib/parlour/options.rb
Overview
A set of immutable formatting options.
Instance Attribute Summary collapse
-
#break_params ⇒ Integer
readonly
If there are at least this many parameters in a signature, then it is broken onto separate lines.
-
#sort_namespaces ⇒ Boolean
readonly
Whether to sort all items within a namespace alphabetically.
-
#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:, sort_namespaces:) ⇒ void
constructor
Creates a new set of formatting options.
Constructor Details
#initialize(break_params:, tab_size:, sort_namespaces:) ⇒ void
Creates a new set of formatting options.
19 20 21 22 23 |
# File 'lib/parlour/options.rb', line 19 def initialize(break_params:, tab_size:, sort_namespaces:) @break_params = break_params @tab_size = tab_size @sort_namespaces = sort_namespaces end |
Instance Attribute Details
#break_params ⇒ Integer (readonly)
If there are at least this many parameters in a signature, 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
43 44 45 |
# File 'lib/parlour/options.rb', line 43 def break_params @break_params end |
#sort_namespaces ⇒ Boolean (readonly)
Whether to sort all items within a namespace alphabetically. Items which are typically grouped together, such as “include” or “extend” calls, will remain grouped together when sorted. If true, items are sorted by their name when the RBI is generated. If false, items are generated in the order they are added to the namespace.
58 59 60 |
# File 'lib/parlour/options.rb', line 58 def sort_namespaces @sort_namespaces end |
#tab_size ⇒ Integer (readonly)
The number of spaces to use per indent.
48 49 50 |
# File 'lib/parlour/options.rb', line 48 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.
67 68 69 |
# File 'lib/parlour/options.rb', line 67 def indented(level, str) " " * (level * tab_size) + str end |