Class: Keydown::Slide
- Inherits:
-
Object
- Object
- Keydown::Slide
- Defined in:
- lib/keydown/slide.rb
Instance Attribute Summary collapse
-
#background_image ⇒ Object
readonly
Returns the value of attribute background_image.
-
#classnames ⇒ Object
readonly
Returns the value of attribute classnames.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
Instance Method Summary collapse
- #background_attribution_classnames ⇒ Object
-
#initialize(text, classnames = '') ⇒ Slide
constructor
A new instance of Slide.
- #to_html ⇒ Object
Constructor Details
#initialize(text, classnames = '') ⇒ Slide
Returns a new instance of Slide.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/keydown/slide.rb', line 9 def initialize(text, classnames = '') @notes = '' @background_image = {} @codemap = CodeMap.build_from(text) @content = @codemap.mapped_text extract_notes! extract_content! extract_background_image! @classnames = Classnames.new('slide') @classnames.add(classnames) unless @background_image.empty? @classnames.add('full-background') @classnames.add(@background_image[:classname]) end end |
Instance Attribute Details
#background_image ⇒ Object (readonly)
Returns the value of attribute background_image.
6 7 8 |
# File 'lib/keydown/slide.rb', line 6 def background_image @background_image end |
#classnames ⇒ Object (readonly)
Returns the value of attribute classnames.
7 8 9 |
# File 'lib/keydown/slide.rb', line 7 def classnames @classnames end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/keydown/slide.rb', line 4 def content @content end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
5 6 7 |
# File 'lib/keydown/slide.rb', line 5 def notes @notes end |
Instance Method Details
#background_attribution_classnames ⇒ Object
29 30 31 32 33 |
# File 'lib/keydown/slide.rb', line 29 def background_attribution_classnames return [] unless background_image[:attribution_text] || background_image[:service] ['attribution', background_image[:service]].join(' ') end |
#to_html ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/keydown/slide.rb', line 35 def to_html require 'tilt' require 'rdiscount' markdown = RDiscount.new(@content) context = OpenStruct.new(:html_content => markdown.to_html, :classnames => classnames.to_hash, :background_attribution_classnames => background_attribution_classnames, :background_image => background_image) = Tilt.new(File.join(Tasks.template_dir, 'slide.html.haml')) html = .render(context) @codemap.put_code_in html end |