Class: Messed::Interface::Adapter
- Inherits:
-
Object
- Object
- Messed::Interface::Adapter
show all
- Includes:
- Logger::LoggingModule
- Defined in:
- lib/messed/interface/adapter.rb,
lib/messed/interface/adapter/twitter_search.rb,
lib/messed/interface/adapter/twitter_sender.rb,
lib/messed/interface/adapter/twitter_consumer.rb,
lib/messed/interface/adapter/twitter_streaming.rb
Defined Under Namespace
Classes: TwitterConsumer, TwitterSearch, TwitterSender, TwitterStreaming
Constant Summary
collapse
- Registry =
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included, #logger, #logger=
Constructor Details
#initialize(interface) ⇒ Adapter
Returns a new instance of Adapter.
34
35
36
37
|
# File 'lib/messed/interface/adapter.rb', line 34
def initialize(interface)
@interface = interface
init
end
|
Instance Attribute Details
#interface ⇒ Object
Returns the value of attribute interface.
32
33
34
|
# File 'lib/messed/interface/adapter.rb', line 32
def interface
@interface
end
|
Class Method Details
.for_name(name) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/messed/interface/adapter.rb', line 25
def self.for_name(name)
class_name = Registry[name]
class_name ?
class_name.constantize :
raise("No adapter for #{name}")
end
|
.register_for_name(name, class_name) ⇒ Object
17
18
19
|
# File 'lib/messed/interface/adapter.rb', line 17
def self.register_for_name(name, class_name)
Registry[name] = class_name
end
|
Instance Method Details
#init ⇒ Object
any post initialization goes here
52
53
|
# File 'lib/messed/interface/adapter.rb', line 52
def init
end
|
#load_state ⇒ Object
43
44
45
|
# File 'lib/messed/interface/adapter.rb', line 43
def load_state
JSON.parse(File.read(state_file))
end
|
#save_state(state) ⇒ Object
39
40
41
|
# File 'lib/messed/interface/adapter.rb', line 39
def save_state(state)
File.open(state_file, 'w') {|f| f << state.to_json }
end
|
#send(message) ⇒ Object
63
64
|
# File 'lib/messed/interface/adapter.rb', line 63
def send(message)
end
|
#start(detach) ⇒ Object
59
60
61
|
# File 'lib/messed/interface/adapter.rb', line 59
def start(detach)
raise "method start must be defined"
end
|
#state_file ⇒ Object
47
48
49
|
# File 'lib/messed/interface/adapter.rb', line 47
def state_file
"/tmp/#{name}.state"
end
|
#type ⇒ Object
55
56
57
|
# File 'lib/messed/interface/adapter.rb', line 55
def type
raise "method type must be defined"
end
|