Class: EditorConfigGenerator::OptionTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/editorconfig/option_transformer.rb

Overview

Transforms options given to an EditorConfig object

Class Method Summary collapse

Class Method Details

.transform_final_newline_option(options) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/editorconfig/option_transformer.rb', line 10

def self.transform_final_newline_option(options)
  if options[:insert_final_newline] == 'y'
    options[:insert_final_newline] = true
  elsif options[:insert_final_newline] == 'n'
    options[:insert_final_newline] = false
  end
end

.transform_options(options) ⇒ Object



4
5
6
7
8
# File 'lib/editorconfig/option_transformer.rb', line 4

def self.transform_options(options)
  transform_root_option(options)
  transform_whitespace_option(options)
  transform_final_newline_option(options)
end

.transform_root_option(options) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/editorconfig/option_transformer.rb', line 26

def self.transform_root_option(options)
  if options[:root] == 'y'
    options[:root] = true
  elsif options[:root] == 'n'
    options[:root] = false
  end
end

.transform_whitespace_option(options) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/editorconfig/option_transformer.rb', line 18

def self.transform_whitespace_option(options)
  if options[:trim_trailing_whitespace] == 'y'
    options[:trim_trailing_whitespace] = true
  elsif options[:trim_trailing_whitespace] == 'n'
    options[:trim_trailing_whitespace] = false
  end
end