Class: MarkdownSlider
- Inherits:
-
Object
- Object
- MarkdownSlider
- Defined in:
- lib/markdown_slider.rb
Constant Summary collapse
- VERSION =
'0.0.3'
Instance Attribute Summary collapse
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#slides ⇒ Object
readonly
Returns the value of attribute slides.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ MarkdownSlider
constructor
A new instance of MarkdownSlider.
- #publish(input) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ MarkdownSlider
Returns a new instance of MarkdownSlider.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/markdown_slider.rb', line 48 def initialize( = {}) @version = MarkdownSlider::VERSION @title = [:title] || 'title' @template = [:template] || MarkdownSlider::TEMPLATE @style = [:style] || MarkdownSlider::STYLE @script = [:script] || MarkdownSlider::SCRIPT @parser = Redcarpet::Markdown.new( Redcarpet::Render::HTML, { :tables => true, :fenced_code_blocks => true, :autolink => true, :strikethrough => true, :space_after_headers => true, } ) end |
Instance Attribute Details
#script ⇒ Object (readonly)
Returns the value of attribute script.
10 11 12 |
# File 'lib/markdown_slider.rb', line 10 def script @script end |
#slides ⇒ Object (readonly)
Returns the value of attribute slides.
10 11 12 |
# File 'lib/markdown_slider.rb', line 10 def @slides end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
10 11 12 |
# File 'lib/markdown_slider.rb', line 10 def style @style end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'lib/markdown_slider.rb', line 10 def title @title end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/markdown_slider.rb', line 10 def version @version end |
Class Method Details
.run(markdown, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/markdown_slider.rb', line 12 def self.run(markdown, = {}) raise ArgumentError, "specified source not found: #{markdown}" unless File.exist?(markdown) input = File::read(markdown) # check options if .has_key?(:template) if File.exist?([:template]) [:template] = File::read([:template]) else raise ArgumentError, "specified template not found: #{[:template]}" end end if .has_key?(:style) if File.exist?([:style]) [:style] = File::read([:style]) else raise ArgumentError, "specified css not found: #{[:style]}" end end if .has_key?(:script) if File.exist?([:script]) [:script] = File::read([:script]) else raise ArgumentError, "specified script not found: #{[:script]}" end end MarkdownSlider.new().publish(input) end |
Instance Method Details
#publish(input) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/markdown_slider.rb', line 70 def publish(input) @slides = split(@parser.render(input)) ERB.new(@template).result(binding) end |