Class: Staticz::Compilable::Js

Inherits:
Object
  • Object
show all
Includes:
Staticz::Compilable
Defined in:
lib/manifest/compilable/js.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Staticz::Compilable

#build_path, #create_link_function, #errors, #exists?, included, #path, #path_method_name, #print, #source_path, #valid?, #warnings

Constructor Details

#initialize(name) ⇒ Js

Returns a new instance of Js.



12
13
14
# File 'lib/manifest/compilable/js.rb', line 12

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/manifest/compilable/js.rb', line 8

def name
  @name
end

Instance Method Details

#build(listener_class: nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/manifest/compilable/js.rb', line 16

def build(listener_class: nil)
  listener = listener_class&.new(self)

  if exists?
    File.write build_path, render

    listener&.finish
  else
    listener&.error
  end
end

#renderObject



28
29
30
# File 'lib/manifest/compilable/js.rb', line 28

def render
  File.read(source_path)
end