Class: Traductor::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/traductor/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/traductor/configuration.rb', line 11

def initialize
  @source_locale = "en"
  @target_locales = []
  @source_paths = []
  @output_dir = nil
  @model = nil
  @provider = nil
  @temperature = 0.3
  @glossary_path = nil
  @batch_size = 30
end

Instance Attribute Details

#batch_size ⇒ Object

Returns the value of attribute batch_size.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def batch_size
  @batch_size
end

#glossary_path ⇒ Object

Returns the value of attribute glossary_path.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def glossary_path
  @glossary_path
end

#model ⇒ Object

Returns the value of attribute model.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def model
  @model
end

#output_dir ⇒ Object

Returns the value of attribute output_dir.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def output_dir
  @output_dir
end

#provider ⇒ Object

Returns the value of attribute provider.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def provider
  @provider
end

#source_locale ⇒ Object

Returns the value of attribute source_locale.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def source_locale
  @source_locale
end

#source_paths ⇒ Object

Returns the value of attribute source_paths.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def source_paths
  @source_paths
end

#target_locales ⇒ Object

Returns the value of attribute target_locales.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def target_locales
  @target_locales
end

#temperature ⇒ Object

Returns the value of attribute temperature.



7
8
9
# File 'lib/traductor/configuration.rb', line 7

def temperature
  @temperature
end

Instance Method Details

#load_from_file(path = ".traductor.yml") ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/traductor/configuration.rb', line 23

def load_from_file(path = ".traductor.yml")
  return unless File.exist?(path)

  yaml = YAML.safe_load_file(path, permitted_classes: [Symbol])
  return unless yaml.is_a?(Hash)

  apply_hash(yaml)
end