Class: Slidr::Commands::SlideCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Slidr::Commands::SlideCommand
- Defined in:
- lib/slidr/commands/slide_command.rb
Instance Method Summary collapse
- #go(content) ⇒ Object
-
#initialize(pattern, slides, filters = {}) ⇒ SlideCommand
constructor
A new instance of SlideCommand.
Methods inherited from BaseCommand
Constructor Details
#initialize(pattern, slides, filters = {}) ⇒ SlideCommand
Returns a new instance of SlideCommand.
6 7 8 9 10 11 |
# File 'lib/slidr/commands/slide_command.rb', line 6 def initialize(pattern, , filters={}) @pattern = pattern @slides = @publish = filters[:publish] @draft = filters[:draft] end |
Instance Method Details
#go(content) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/slidr/commands/slide_command.rb', line 13 def go(content) = [] if @publish == :all = @slides else @slides.each do || class_attrib = .lines.grep(/^class: [a-zA-Z0-9 ,:-]+$/) if @publish.any? { |cond| class_attrib.empty? ? false : class_attrib.first.include?(":#{ cond }") } << end end end = .map { || .sub(/^---$/, '').strip }.join("\n---\n") content.sub(@pattern, ) end |