Class: Arbi::Modules::Module
- Inherits:
-
Object
- Object
- Arbi::Modules::Module
show all
- Defined in:
- lib/arbi/modules.rb
Direct Known Subclasses
Acpi::Adapter, Acpi::Battery, Cpu, Diskstat, Help, Net, Ram, Sys::Adapter, Sys::Battery, Sys::Thermal, Version
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data = []) ⇒ Module
Returns a new instance of Module.
58
59
60
|
# File 'lib/arbi/modules.rb', line 58
def initialize(data = [])
@data = data
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
56
57
58
|
# File 'lib/arbi/modules.rb', line 56
def data
@data
end
|
Class Method Details
.__method_missing__ ⇒ Object
104
|
# File 'lib/arbi/modules.rb', line 104
alias __method_missing__ method_missing
|
.inherited(obj) ⇒ Object
89
90
91
92
93
94
|
# File 'lib/arbi/modules.rb', line 89
def inherited(obj)
@@modules ||= {}
Singleton.__init__(obj)
Arbi::Modules.uninit
@@modules[obj.name] = obj
end
|
.json_create(o) ⇒ Object
85
86
87
|
# File 'lib/arbi/modules.rb', line 85
def json_create(o)
self.new(o['data'])
end
|
.method_missing(sym, *args, &blk) ⇒ Object
105
106
107
108
109
110
111
|
# File 'lib/arbi/modules.rb', line 105
def method_missing(sym, *args, &blk)
if self.instance.respond_to?(sym)
self.instance.send(sym, *args, &blk)
else
self.__method_missing__(sym, *args, &blk)
end
end
|
.modules ⇒ Object
96
97
98
|
# File 'lib/arbi/modules.rb', line 96
def modules
@@modules
end
|
.name ⇒ Object
100
101
102
|
# File 'lib/arbi/modules.rb', line 100
def name
self.to_s.downcase.split('::').last
end
|
Instance Method Details
#every(ev = 2, args = {}, &blk) ⇒ Object
62
63
64
65
|
# File 'lib/arbi/modules.rb', line 62
def every(ev = 2, args = {}, &blk)
args[:timeout] ||= 5
TimeLine::Job.new(ev, args[:timeout], &blk)
end
|
76
77
78
|
# File 'lib/arbi/modules.rb', line 76
def format
"#{self.class.name} has no format specified, writing raw:\n#{data.to_json}"
end
|
#to_json(*a) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'lib/arbi/modules.rb', line 67
def to_json(*a)
self.refresh if self.respond_to?(:refresh)
{
'json_class' => self.class.to_s,
'data' => @data
}.to_json(*a) + "\n"
end
|
#valid? ⇒ Boolean
80
81
82
|
# File 'lib/arbi/modules.rb', line 80
def valid?
false
end
|