Class: RailsLiveReload::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_live_reload/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Command

Returns a new instance of Command.



5
6
7
8
# File 'lib/rails_live_reload/command.rb', line 5

def initialize(params)
  @dt    = params["dt"].to_i
  @files = JSON.parse(params["files"]) rescue []
end

Instance Attribute Details

#dtObject (readonly)

Returns the value of attribute dt.



3
4
5
# File 'lib/rails_live_reload/command.rb', line 3

def dt
  @dt
end

#filesObject (readonly)

Returns the value of attribute files.



3
4
5
# File 'lib/rails_live_reload/command.rb', line 3

def files
  @files
end

Instance Method Details

#changesObject



10
11
12
# File 'lib/rails_live_reload/command.rb', line 10

def changes
  RailsLiveReload::Checker.scan(dt, files)
end

#payloadObject



18
19
20
21
22
23
24
# File 'lib/rails_live_reload/command.rb', line 18

def payload
  if reload?
    { command: "RELOAD" }
  else
    { command: "NO_CHANGES" }
  end
end

#reload?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rails_live_reload/command.rb', line 14

def reload?
  !changes.size.zero?
end