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.
-
#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
- #classnames ⇒ Object
- #container_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.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/keydown/slide.rb', line 8 def initialize(text, classnames = '') @content = text @notes = '' @codemap = {} @background_image = {} @classnames = [] classnames.split(' ').inject(@classnames) do |css_classnames, name| css_classnames << name css_classnames end extract_notes! extract_content! extract_code! extract_background_image! highlight_code! 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 |
#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
44 45 46 47 48 |
# File 'lib/keydown/slide.rb', line 44 def background_attribution_classnames return [] unless background_image[:attribution_text] || background_image[:service] ['attribution', background_image[:service]].join(' ') end |
#classnames ⇒ Object
27 28 29 |
# File 'lib/keydown/slide.rb', line 27 def classnames @classnames.length > 0 ? { :class => @classnames.join(' ') } : {} end |
#container_classnames ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/keydown/slide.rb', line 31 def container_classnames @names ||= begin names = ['slide'] unless @background_image.empty? names << 'full-background' names << @background_image[:classname] end names.join(' ') end end |
#to_html ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/keydown/slide.rb', line 50 def to_html require 'tilt' require 'rdiscount' markdown = RDiscount.new(@content) context = OpenStruct.new(:html_content => markdown.to_html, :container_classnames => container_classnames, :classnames => classnames, :background_attribution_classnames => background_attribution_classnames, :background_image => background_image) = Tilt.new(File.join(Tasks.template_dir, 'slide.html.haml')) .render(context) end |