Class: Yasd::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/yasd/converter.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Converter

Returns a new instance of Converter.



5
6
7
8
9
10
11
# File 'lib/yasd/converter.rb', line 5

def initialize(filename)
  @converters = {}
  if filename
    contents = File.read(filename)
    instance_eval(contents)
  end
end

Instance Method Details

#call(data) ⇒ Object



13
14
15
16
17
18
# File 'lib/yasd/converter.rb', line 13

def call(data)
  data.headers.each_with_object({}) do |field, new_object|
    new_object[field] = convert_field(field, data[field])
    new_object
  end
end