Class: Timeline
- Inherits:
-
Object
- Object
- Timeline
- Defined in:
- lib/timeline.rb
Overview
Contains all the data and settings for a single Simile timeline
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(options) ⇒ Timeline
constructor
The main options that can be given to the timeline are .
- #timeline_config ⇒ Object
- #timeline_data ⇒ Object
Constructor Details
#initialize(options) ⇒ Timeline
The main options that can be given to the timeline are
- config
-
The configuration for timeline, including the bands configuration. This will be directly passed on to timline.js, see there for more documentation. If no :bands option is given, a default band is created for the timeline.
- data
-
A TimelineSource object containing the data for this timeline OR a hash with the options to create the TimelineSource
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/timeline.rb', line 15 def initialize() raise(ArgumentError, 'Expecting an option hash here.') unless(.is_a?(Hash)) . raise(ArgumentError, 'Expecting some data here') unless([:data]) raise(ArgumentError, 'Expecting the configuration here') unless([:config]) if([:data].is_a?(TimelineSource)) @data = [:data] else @data = TimelineSource.new([:data]) end @config = [:config]. @config[:startDate] ||= year_to_iso8601(@data.first_year) if(@data.first_year) @config[:stopDate] ||= year_to_iso8601(@data.last_year) if(@data.last_year) @default_date ||= year_to_iso8601(@data.first_year + ((@data.last_year - @data.first_year) / 2)) if(@data.first_year && @data.last_year) @config[:bands] ||= default_band end |
Instance Method Details
#empty? ⇒ Boolean
38 39 40 |
# File 'lib/timeline.rb', line 38 def empty? @data.empty? end |
#timeline_config ⇒ Object
34 35 36 |
# File 'lib/timeline.rb', line 34 def timeline_config @config.to_json end |
#timeline_data ⇒ Object
42 43 44 |
# File 'lib/timeline.rb', line 42 def timeline_data @data.timeline_data end |