lib/timeline_source.rb in muruca_widgets-0.1.0 vs lib/timeline_source.rb in muruca_widgets-0.2.0
- old
+ new
@@ -84,18 +84,22 @@
def self.to_iso8601(date)
return nil unless(date)
date.strftime('%Y-%m-%dT%H:%M:%SZ')
end
+ def empty?
+ @events.empty?
+ end
+
private
# Check the options and set them to the default values if necessary
def process_options(options)
options.to_options!
options[:dateTimeFormat] ||= 'iso8601'
# Check if we have one data source option given
- exactly_one_source = options[:sources] ^ options[:source_finder] ^ options[:raw_data]
+ exactly_one_source = (options[:sources] != nil) ^ (options[:source_finder] != nil) ^ (options[:raw_data] != nil)
# We could also all three options given - there should be at least one false, d'oh
exactly_one_source = (exactly_one_source && (!options[:sources] || !options[:source_finder]))
raise(ArgumentError, "Must give exactly one of :raw_data, :sources or :source_finder") unless(exactly_one_source)
# Check - we don't want those options for :raw_data
if(options[:raw_data])
@@ -166,10 +170,14 @@
# new_event['image'] = ''
# The link field may either be filled from a property, or with a link to the element itself (default)
new_event[:link] = if(@options[:link_property])
src[@options[:link_property]].first || ''
else
- (N::LOCAL + N::URI.new(src.uri).local_name).to_s
+ if((uri = src.to_uri).local?)
+ '/' << uri.local_name
+ else
+ uri.to_s
+ end
end
# We have a duration event if we have a non-nil end date
new_event[:duration_event] = true unless(new_event[:end])
# new_event[:icon] = 'red_circle.png'
# Colors as defined in the options
\ No newline at end of file