Class: JsGenerator::ViewFile

Inherits:
Object
  • Object
show all
Defined in:
lib/js_generator/view_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setup_js, syntax_builder) ⇒ ViewFile

Returns a new instance of ViewFile.



5
6
7
8
9
10
# File 'lib/js_generator/view_file.rb', line 5

def initialize(setup_js, syntax_builder)
  @namespace = setup_js.namespace
  @model_name = setup_js.model_name
  @action_name = setup_js.action_name
  @syntax_builder = syntax_builder
end

Instance Attribute Details

#action_nameObject (readonly)

Returns the value of attribute action_name.



3
4
5
# File 'lib/js_generator/view_file.rb', line 3

def action_name
  @action_name
end

#model_nameObject (readonly)

Returns the value of attribute model_name.



3
4
5
# File 'lib/js_generator/view_file.rb', line 3

def model_name
  @model_name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



3
4
5
# File 'lib/js_generator/view_file.rb', line 3

def namespace
  @namespace
end

#syntax_builderObject (readonly)

Returns the value of attribute syntax_builder.



3
4
5
# File 'lib/js_generator/view_file.rb', line 3

def syntax_builder
  @syntax_builder
end

Instance Method Details

#append_script_tagObject



12
13
14
15
16
# File 'lib/js_generator/view_file.rb', line 12

def append_script_tag
  File.open(file_path, 'a') { |f| f << script_tag }

  puts "📝 Appended <script> tag to #{file_path}"
end