Class: Viberator::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/viberator/writer.rb

Constant Summary collapse

TEMPLATE =
Slim::Template.new "#{__dir__}/template.slim"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chat) ⇒ Writer

Returns a new instance of Writer.



15
16
17
# File 'lib/viberator/writer.rb', line 15

def initialize(chat)
  @chat = chat
end

Instance Attribute Details

#chatObject (readonly)

Returns the value of attribute chat.



13
14
15
# File 'lib/viberator/writer.rb', line 13

def chat
  @chat
end

Instance Method Details

#write(output) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/viberator/writer.rb', line 19

def write(output)
  @output    = Pathname.new output
  @assets    = @output.join "assets"
  @processed = {}

  fail "Output path already exists! Halt!" if @output.exist?

  @output.mkdir
  @assets.mkdir

  @output.join("index.html").open "w" do |io|
    io << TEMPLATE.render(self)
  end
end