Class: Filename
- Inherits:
-
Object
- Object
- Filename
- Defined in:
- lib/filename.rb,
lib/filename/version.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(base, *extensions) ⇒ Filename
constructor
A new instance of Filename.
- #prefix(*values, seperator: '_') ⇒ Object
- #suffix(*values, seperator: '_') ⇒ Object
- #to_s ⇒ Object (also: #to_path)
Constructor Details
#initialize(base, *extensions) ⇒ Filename
Returns a new instance of Filename.
8 9 10 |
# File 'lib/filename.rb', line 8 def initialize(base, *extensions) @base, @extensions = clean(base), clean(extensions) end |
Class Method Details
.parse(value) ⇒ Object
4 5 6 |
# File 'lib/filename.rb', line 4 def self.parse(value) new *value.to_s.split('.') end |
Instance Method Details
#prefix(*values, seperator: '_') ⇒ Object
16 17 18 |
# File 'lib/filename.rb', line 16 def prefix(*values, seperator: '_') @base.unshift(clean(values).push('').join(seperator)) && self end |
#suffix(*values, seperator: '_') ⇒ Object
12 13 14 |
# File 'lib/filename.rb', line 12 def suffix(*values, seperator: '_') @base.push(clean(values).unshift('').join(seperator)) && self end |
#to_s ⇒ Object Also known as: to_path
20 21 22 |
# File 'lib/filename.rb', line 20 def to_s @extensions.unshift(@base.join).join('.') end |