Class: Submarine::Configuration

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*attrs) ⇒ Configuration

Constructs a new Configuration instance. Merges passed in options hash, sets instance variables.



9
10
11
12
13
# File 'lib/submarine/configuration.rb', line 9

def initialize *attrs
  options = attrs.empty? ? {} : attrs.first
  options = self.class.defaults.merge(options)
  set_instance_variables options
end

Instance Attribute Details

#format_keyObject

Acceptable accessors.



4
5
6
# File 'lib/submarine/configuration.rb', line 4

def format_key
  @format_key
end

#left_delimiterObject

Acceptable accessors.



4
5
6
# File 'lib/submarine/configuration.rb', line 4

def left_delimiter
  @left_delimiter
end

#right_delimiterObject

Acceptable accessors.



4
5
6
# File 'lib/submarine/configuration.rb', line 4

def right_delimiter
  @right_delimiter
end

#substitutionsObject

Acceptable accessors.



4
5
6
# File 'lib/submarine/configuration.rb', line 4

def substitutions
  @substitutions
end

Class Method Details

.defaultsObject

Configuration defaults.



17
18
19
20
21
22
23
24
# File 'lib/submarine/configuration.rb', line 17

def self.defaults
  {
    format_key:      :text, # The key representing the string to be formatted
    left_delimiter:  '[[',  # The left-side matching string, ie: '[[name]]'
    right_delimiter: ']]',  # The right-side matching string, ie: '[[name]]'
    substitutions:   {}     # Optional global default substitutions 
  }
end

Instance Method Details

#reload!Object

Reload the Configuration instance variables to defaults.



28
29
30
# File 'lib/submarine/configuration.rb', line 28

def reload!
  set_instance_variables(self.class.defaults)
end