Class: Guard::LiveReload::Snippet
- Inherits:
-
Object
- Object
- Guard::LiveReload::Snippet
- Defined in:
- lib/guard/livereload/snippet.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(template, options) ⇒ Snippet
constructor
A new instance of Snippet.
Constructor Details
#initialize(template, options) ⇒ Snippet
Returns a new instance of Snippet.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/guard/livereload/snippet.rb', line 12 def initialize(template, ) @options = # for ERB context # NOTE: use instance variable for Tempfile, so it's not GC'ed before sending @tmpfile = Tempfile.new('livereload.js') source = IO.read(template) data = ERB.new(source).result(binding) @tmpfile.write(data) @tmpfile.close @path = @tmpfile.path end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/guard/livereload/snippet.rb', line 10 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/guard/livereload/snippet.rb', line 9 def path @path end |