Class: Staticz::Compilable::React
- Inherits:
-
Object
- Object
- Staticz::Compilable::React
- Includes:
- Staticz::Compilable
- Defined in:
- lib/manifest/compilable/react.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #build(listener_class: nil) ⇒ Object
-
#initialize(name) ⇒ React
constructor
A new instance of React.
- #render ⇒ Object
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) ⇒ React
Returns a new instance of React.
13 14 15 |
# File 'lib/manifest/compilable/react.rb', line 13 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/manifest/compilable/react.rb', line 9 def name @name end |
Instance Method Details
#build(listener_class: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/manifest/compilable/react.rb', line 17 def build(listener_class: nil) listener = listener_class&.new(self) if exists? File.write build_path, render listener&.finish else listener&.error end end |
#render ⇒ Object
29 30 31 |
# File 'lib/manifest/compilable/react.rb', line 29 def render Babel::Transpiler.transform(File.read(source_path))["code"] end |