Class: Parade::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/parade/metadata.rb,
lib/parade/metadata/html_id.rb,
lib/parade/metadata/template.rb,
lib/parade/metadata/assignment.rb,
lib/parade/metadata/css_classes.rb

Overview

Slides within Parade contain metadata. This metadata allows you to set CSS classes and IDs. You are also able, as well to assigna unique transitions between each slide.

Defined Under Namespace

Classes: Assignment, CSSClasses, HTMLId, Template

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Metadata

The initialize method is generally not called directly and instead is used through the Metadata.parse method.

Parameters:

  • params (Hash) (defaults to: {})

    this hash contains the key-value pairs that map directly to accessor methods within the Metadata class.

See Also:



57
58
59
# File 'lib/parade/metadata.rb', line 57

def initialize(params = {})
  params.each {|k,v| send("#{k}=",v) if respond_to? "#{k}=" }
end

Instance Attribute Details

#classesObject



63
64
65
# File 'lib/parade/metadata.rb', line 63

def classes
  @classes || []
end

#idObject

Returns the value of attribute id.



67
68
69
# File 'lib/parade/metadata.rb', line 67

def id
  @id
end

#templateObject

Returns the value of attribute template.



69
70
71
# File 'lib/parade/metadata.rb', line 69

def template
  @template
end

#transitionObject

Returns the value of attribute transition.



68
69
70
# File 'lib/parade/metadata.rb', line 68

def transition
  @transition
end

Class Method Details

.parse(metadata) ⇒ Object

Examples:

Raw Metadata that contains CSS Class, ID, transitions, and template data


 = Metadata.parse "transition=fade one two #id three tpl=template_name"
.classes # => [ 'one', 'two', 'three' ]
.transition # => 'fade'
.id # => 'id'
.template # => 'template_name'

Parameters:

  • metadata (String)

    a single string that contains all the raw metadata.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/parade/metadata.rb', line 26

def self.parse()

   = {}

  .to_s.split(' ').each do |term|
     = parsers.find {|parser| parser.match? term }
    .apply(term,)
  end

  self.new 
end

.parsersObject

The list of the parsers that are used to parse the metadata string.



41
42
43
44
45
46
# File 'lib/parade/metadata.rb', line 41

def self.parsers
  [ Template.new,
    Assignment.new,
    HTMLId.new,
    CSSClasses.new ]
end