Class: FLACsmith::Metadata::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/flacsmith/metadata/formatter.rb

Overview

Converts text into a key/value pair.

Instance Method Summary collapse

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_hObject



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