Class: SistemKebut::Transformasi::Web

Inherits:
Object
  • Object
show all
Defined in:
lib/transformasi/web.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Web

Returns a new instance of Web.



6
7
8
9
10
# File 'lib/transformasi/web.rb', line 6

def initialize(data)
  @data = data
  @jumlah = @data.length
  @konten = nil
end

Class Method Details

.kelola(data) ⇒ Object



29
30
31
# File 'lib/transformasi/web.rb', line 29

def self.kelola(data)
  new(data).kirim.olah_data
end

Instance Method Details

#kirimObject



12
13
14
15
16
17
18
# File 'lib/transformasi/web.rb', line 12

def kirim
  angkat = YAML.dump(@data)
  KebutSemalam::Web::WebGenerate.new(angkat).tap do |web|
    @konten = web.konten
  end
  return self
end

#olah_dataObject



20
21
22
23
24
25
26
27
# File 'lib/transformasi/web.rb', line 20

def olah_data
  return nil if @konten.nil?
  keterangan = YAML.unsafe_load(@konten)
  @jumlah.times do |i|
    @data[i] = keterangan[i]
  end
  return nil
end