Class: FSEvent::AbstractDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/fsevent/abstractdevice.rb

Overview

Abstract class for devices

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device_name) ⇒ AbstractDevice

Returns a new instance of AbstractDevice.



21
22
23
24
25
# File 'lib/fsevent/abstractdevice.rb', line 21

def initialize(device_name)
  @name = device_name
  @current_status = {}
  @schedule = FSEvent::ScheduleMerger.new
end

Instance Attribute Details

#framework=(value) ⇒ Object (writeonly)

Sets the attribute framework

Parameters:

  • value

    the value to set the attribute framework to.



27
28
29
# File 'lib/fsevent/abstractdevice.rb', line 27

def framework=(value)
  @framework = value
end

#nameObject (readonly)

Returns the value of attribute name.



26
27
28
# File 'lib/fsevent/abstractdevice.rb', line 26

def name
  @name
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



26
27
28
# File 'lib/fsevent/abstractdevice.rb', line 26

def schedule
  @schedule
end

Instance Method Details

#add_watch(watchee_device_name, status_name, reaction = :immediate) ⇒ Object



52
53
54
# File 'lib/fsevent/abstractdevice.rb', line 52

def add_watch(watchee_device_name, status_name, reaction = :immediate)
  @framework.add_watch(watchee_device_name, status_name, reaction)
end

#define_status(status_name, value) ⇒ Object



56
57
58
# File 'lib/fsevent/abstractdevice.rb', line 56

def define_status(status_name, value)
  @framework.define_status(status_name, value)
end

#registeredObject

Called from the framework when this device is registered.



30
31
32
33
34
35
36
# File 'lib/fsevent/abstractdevice.rb', line 30

def registered
  # child process calls:
  # * @framework.add_watch
  # * @framework.define_status
  # * @framework.status_changed # possible but needless
  # * @framework.set_elapsed_time
end

#run(watched_status_change) ⇒ Object

Called from the framework

Raises:

  • (NotImplementedError)


43
44
45
46
47
48
49
50
# File 'lib/fsevent/abstractdevice.rb', line 43

def run(watched_status_change)
  raise NotImplementedError
  # child process calls:
  # * @framework.add_watch # possible but should be rare
  # * @framework.define_status # possible but should be rare
  # * @framework.status_changed
  # * @framework.set_elapsed_time
end

#set_elapsed_time(t) ⇒ Object



68
69
70
# File 'lib/fsevent/abstractdevice.rb', line 68

def set_elapsed_time(t)
  @framework.set_elapsed_time(t)
end

#status_changed(status_name, value) ⇒ Object



60
61
62
# File 'lib/fsevent/abstractdevice.rb', line 60

def status_changed(status_name, value)
  @framework.status_changed(status_name, value)
end

#unregister_device(device_name) ⇒ Object



64
65
66
# File 'lib/fsevent/abstractdevice.rb', line 64

def unregister_device(device_name)
  @framework.unregister_device(device_name)
end

#unregisteredObject

Called from the framework when this device is unregistered.



39
40
# File 'lib/fsevent/abstractdevice.rb', line 39

def unregistered
end