Sha256: b3f6e44e434a2af5658ffe087fa0454d5f311d71a68ba5127c25ed53fff568a6
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module Sched class Event SCHED_ATTRIBUTES = [ # Required :event_key, :name, :event_start, :event_end, :event_type, # Optional :event_subtype, :description, :panelists, :url, :media_url, :venue, :address, :map, :tags, :active ] SCHED_ATTRIBUTES.each{ |attribute| attr_accessor attribute } attr_accessor :client def initialize(event_key, client=nil) @event_key = event_key @client = client end def get_attribute(key) self.send("#{key}") end def configure(options={}) options.each do |key, value| if SCHED_ATTRIBUTES.include?(key) self.send("#{key.to_s}=", value) end end self end def data data = {} SCHED_ATTRIBUTES.each do |attribute| unless self.get_attribute(attribute) === nil value = self.get_attribute(attribute) value = 'Y' if value === true value = 'N' if value === false data[attribute] = value end end data end def save if self.exists? self.update else self.create end end def create self.client.request('event/add', self.data) end def update self.client.request('event/mod', self.data) end def exists? client.events.map{|e| e.event_key}.include?(self.event_key) ? true : false end def destroy self.client.request('event/del', {:event_key => self.event_key}) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sched-0.0.6 | lib/sched/event.rb |
sched-0.0.5 | lib/sched/event.rb |