Class: FFXI::Util::RubyBean
- Inherits:
-
Object
- Object
- FFXI::Util::RubyBean
show all
- Defined in:
- lib/util/ruby_bean.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of RubyBean.
5
6
7
|
# File 'lib/util/ruby_bean.rb', line 5
def initialize
@listeners = []
end
|
Class Method Details
.property(*properties) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/util/ruby_bean.rb', line 21
def self.property(*properties)
properties.each do |p|
value = nil
define_method(p) { return value }
define_method("#{p}=") do |new_value|
return if value == new_value
@listeners.each do |l|
l.property_changed(p, value, new_value)
end
value = new_value
end
protected("#{p}=")
end
end
|
Instance Method Details
#add_listener(l) ⇒ Object
9
10
11
|
# File 'lib/util/ruby_bean.rb', line 9
def add_listener(l)
@listeners.push(l) unless @listeners.include?(l)
end
|
#has_listeners? ⇒ Boolean
17
18
19
|
# File 'lib/util/ruby_bean.rb', line 17
def has_listeners?
! @listeners.empty?
end
|
#remove_listener(l) ⇒ Object
13
14
15
|
# File 'lib/util/ruby_bean.rb', line 13
def remove_listener(l)
@listeners.delete(l)
end
|