Class: A4Tools::EventManager
- Inherits:
-
Object
- Object
- A4Tools::EventManager
- Defined in:
- lib/event_manager.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
Instance Method Summary collapse
- #event(id) ⇒ Object
-
#initialize(events = nil) ⇒ EventManager
constructor
A new instance of EventManager.
- #transform_events(events) ⇒ Object
Constructor Details
#initialize(events = nil) ⇒ EventManager
Returns a new instance of EventManager.
5 6 7 8 9 10 11 |
# File 'lib/event_manager.rb', line 5 def initialize(events=nil) events = File.read(File.join(File.dirname(__FILE__), "events.json")) if events.nil? events = File.read(events) if events.is_a? String and File.exists? events events = JSON.parse(events) if events.is_a? String @events = transform_events(events) end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
3 4 5 |
# File 'lib/event_manager.rb', line 3 def events @events end |
Instance Method Details
#event(id) ⇒ Object
19 20 21 22 |
# File 'lib/event_manager.rb', line 19 def event(id) @events.each { |event| return event if event[:code] == id.to_i or event[:key] == id.to_sym } nil end |