Class: Guard::LiveReload::Snippet

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/livereload/snippet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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)
  @options = 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

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/guard/livereload/snippet.rb', line 10

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/guard/livereload/snippet.rb', line 9

def path
  @path
end