Class: RhetButler::Slide

Inherits:
YamlType show all
Defined in:
lib/rhet-butler/slide.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from YamlType

#check_config_hash, #init_with, #initialize, register, #value_from_config

Constructor Details

This class inherits a constructor from RhetButler::YamlType

Instance Attribute Details

#config_hashObject (readonly)

Returns the value of attribute config_hash.



89
90
91
# File 'lib/rhet-butler/slide.rb', line 89

def config_hash
  @config_hash
end

#contentObject

Returns the value of attribute content.



91
92
93
# File 'lib/rhet-butler/slide.rb', line 91

def content
  @content
end

#content_filtersObject

Returns the value of attribute content_filters.



93
94
95
# File 'lib/rhet-butler/slide.rb', line 93

def content_filters
  @content_filters
end

#html_classesObject

Returns the value of attribute html_classes.



92
93
94
# File 'lib/rhet-butler/slide.rb', line 92

def html_classes
  @html_classes
end

#html_idObject

Returns the value of attribute html_id.



92
93
94
# File 'lib/rhet-butler/slide.rb', line 92

def html_id
  @html_id
end

#note_filtersObject

Returns the value of attribute note_filters.



93
94
95
# File 'lib/rhet-butler/slide.rb', line 93

def note_filters
  @note_filters
end

#notesObject

Returns the value of attribute notes.



91
92
93
# File 'lib/rhet-butler/slide.rb', line 91

def notes
  @notes
end

#raw_contentObject

Returns the value of attribute raw_content.



90
91
92
# File 'lib/rhet-butler/slide.rb', line 90

def raw_content
  @raw_content
end

#raw_notesObject

Returns the value of attribute raw_notes.



90
91
92
# File 'lib/rhet-butler/slide.rb', line 90

def raw_notes
  @raw_notes
end

#template_nameObject (readonly)

Returns the value of attribute template_name.



94
95
96
# File 'lib/rhet-butler/slide.rb', line 94

def template_name
  @template_name
end

Class Method Details

.optional_configObject



8
9
10
11
12
13
# File 'lib/rhet-butler/slide.rb', line 8

def optional_config
  %w[
    title html_id html_classes html_class
    notes filters note_filters
  ]
end

.required_configObject



15
16
17
# File 'lib/rhet-butler/slide.rb', line 15

def required_config
  %w[content]
end

Instance Method Details

#classesObject



108
109
110
# File 'lib/rhet-butler/slide.rb', line 108

def classes
  @html_classes.join(" ")
end

#configureObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/rhet-butler/slide.rb', line 49

def configure
  value_from_config("title") do |title|
    @html_id = title.downcase.split(/\s/).join("-")
  end

  value_from_config("content") do |content|
    @raw_content = content
  end

  value_from_config("notes") do |notes|
    @raw_notes = notes
  end

  value_from_config("html_id") do |value|
    @html_id = value
  end

  value_from_config("html_classes") do |value|
    @html_classes += [*value]
  end

  value_from_config("html_class") do |value|
    @html_classes << value
  end

  value_from_config("filters") do |value|
    @content_filters = value
    @html_classes += [*value].map do |filter|
      filter.html_class
    end.compact
  end

  value_from_config("note-filters") do |value|
    @note_filters = value
    @html_classes += value.map do |filter|
      "notes-" + filter.html_class unless filter.html_class.nil?
    end
  end
end

#id_attrObject



100
101
102
103
104
105
106
# File 'lib/rhet-butler/slide.rb', line 100

def id_attr
  if @html_id.nil?
    return ""
  else
    "id='#@html_id'"
  end
end

#initialize_copy(source) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/rhet-butler/slide.rb', line 28

def initialize_copy(source)
  super
  @config_hash = source.config_hash.dup unless source.config_hash.nil?
  @content = source.content.dup unless source.content.nil?
  @notes = source.notes.dup unless source.notes.nil?
  @html_id = source.html_id.dup unless source.html_id.nil?
  @html_classes = source.html_classes.dup unless source.html_classes.nil?
end

#normalize_config(coder) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/rhet-butler/slide.rb', line 38

def normalize_config(coder)
  case coder.type
  when :map
    coder.map
  when :scalar
    { 'content' => coder.scalar.to_s }
  when :seq
    { 'content' => coder.seq.to_a }
  end
end

#setup_defaultsObject



20
21
22
23
24
25
26
# File 'lib/rhet-butler/slide.rb', line 20

def setup_defaults
  @template_name = "slide.html"
  @html_classes = ["slide"]
  @html_id = nil
  @raw_notes = ""
  @type = nil
end

#to_sObject



96
97
98
# File 'lib/rhet-butler/slide.rb', line 96

def to_s
  "Slide: #{content.nil? ? "R:#{raw_content[0..20]}" : content[0..20]}"
end