Class: GreenMonster::Decoder
- Inherits:
-
Object
- Object
- GreenMonster::Decoder
- Defined in:
- lib/green_monster/decoder.rb
Instance Method Summary collapse
-
#convert(row, &block) ⇒ Object
変換.
-
#initialize(schema) ⇒ Decoder
constructor
初期化.
Constructor Details
#initialize(schema) ⇒ Decoder
初期化
4 5 6 |
# File 'lib/green_monster/decoder.rb', line 4 def initialize(schema) @schema = schema end |
Instance Method Details
#convert(row, &block) ⇒ Object
変換
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/green_monster/decoder.rb', line 9 def convert(row, &block) attrs = {} @schema.attributes.each do |attribute| attrs.update( attribute.name => attribute.decode(fetch_value(row[attribute.[:col_num]])) ) end block.call(attrs) if block_given? attrs end |