Class: Approvals::Namers::DefaultNamer
- Inherits:
-
Object
- Object
- Approvals::Namers::DefaultNamer
- Defined in:
- lib/approvals/namers/default_namer.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ DefaultNamer
constructor
A new instance of DefaultNamer.
- #normalize(string) ⇒ Object
- #output_dir ⇒ Object
Constructor Details
#initialize(name = nil) ⇒ DefaultNamer
Returns a new instance of DefaultNamer.
6 7 8 9 |
# File 'lib/approvals/namers/default_namer.rb', line 6 def initialize(name = nil) raise ArgumentError.new("DefaultNamer: You must specify a name") if name.nil? @name = normalize(name) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/approvals/namers/default_namer.rb', line 5 def name @name end |
Instance Method Details
#normalize(string) ⇒ Object
11 12 13 |
# File 'lib/approvals/namers/default_namer.rb', line 11 def normalize(string) string.strip.squeeze(" ").gsub(/[\ :-]+/, '_').gsub(/[\W]/, '').downcase end |
#output_dir ⇒ Object
15 16 17 |
# File 'lib/approvals/namers/default_namer.rb', line 15 def output_dir @output_dir ||= Approvals.configuration.approvals_path end |