Class: FLACsmith::Metadata::Formatter
- Inherits:
-
Object
- Object
- FLACsmith::Metadata::Formatter
- Defined in:
- lib/flacsmith/metadata/formatter.rb
Overview
Converts text into a key/value pair.
Instance Method Summary collapse
-
#initialize(text) ⇒ Formatter
constructor
A new instance of Formatter.
- #to_h ⇒ Object
Constructor Details
#initialize(text) ⇒ Formatter
Returns a new instance of Formatter.
7 8 9 |
# File 'lib/flacsmith/metadata/formatter.rb', line 7 def initialize text @text = String text end |
Instance Method Details
#to_h ⇒ Object
11 12 13 14 15 16 |
# File 'lib/flacsmith/metadata/formatter.rb', line 11 def to_h text.split("\n").reduce({}) do |new_hash, line| key, value = line.split "=" new_hash.merge key => value end end |