Class: RailsLiveReload::Command
- Inherits:
-
Object
- Object
- RailsLiveReload::Command
- Defined in:
- lib/rails_live_reload/command.rb
Instance Attribute Summary collapse
-
#dt ⇒ Object
readonly
Returns the value of attribute dt.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #changes ⇒ Object
-
#initialize(params) ⇒ Command
constructor
A new instance of Command.
- #payload ⇒ Object
- #reload? ⇒ Boolean
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
#dt ⇒ Object (readonly)
Returns the value of attribute dt.
3 4 5 |
# File 'lib/rails_live_reload/command.rb', line 3 def dt @dt end |
#files ⇒ Object (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
#changes ⇒ Object
10 11 12 |
# File 'lib/rails_live_reload/command.rb', line 10 def changes RailsLiveReload::Checker.scan(dt, files) end |
#payload ⇒ Object
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
14 15 16 |
# File 'lib/rails_live_reload/command.rb', line 14 def reload? !changes.size.zero? end |