Class: Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/puer/converters.rb

Overview

Converters converts data in the xib files property bag to the NodeInfos property bag. The output key it will have is stored here. The converter can be created with a conversion block Converter.new :output {|v| Convert value v hereā€¦}

Direct Known Subclasses

MultiConverter

Instance Method Summary collapse

Constructor Details

#initialize(output, &conversion) ⇒ Converter

Returns a new instance of Converter.



6
7
8
9
# File 'lib/puer/converters.rb', line 6

def initialize(output, &conversion)
  @output = output
  @conversion = conversion || proc {|v| v}
end

Instance Method Details

#props_for(value) ⇒ Object



11
12
13
14
15
16
# File 'lib/puer/converters.rb', line 11

def props_for(value)
  converted_value = @conversion.call(value)
  if converted_value
    { @output => converted_value }
  end
end