Class: Rabbit::Parser::Image

Inherits:
Base
  • Object
show all
Includes:
Element
Defined in:
lib/rabbit/parser/image.rb

Constant Summary

Constants included from ModuleLoader

ModuleLoader::LOADERS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from ModuleLoader

extend_object, #find_loader, #loaders, #push_loader, #unshift_loader

Constructor Details

This class inherits a constructor from Rabbit::Parser::Base

Class Method Details

.format_nameObject



13
14
15
# File 'lib/rabbit/parser/image.rb', line 13

def format_name
  "image"
end

.match?(source) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rabbit/parser/image.rb', line 17

def match?(source)
  options = {
    :prefix => "image-parser-match",
    :source  => source,
  }
  Rabbit::TemporaryFile.create(options) do |input|
    begin
      Rabbit::ImageLoader.new(input.path)
      true
    rescue Rabbit::ImageLoadError
      false
    end
  end
end

Instance Method Details

#parseObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/rabbit/parser/image.rb', line 34

def parse
  options = {
    :prefix => "image-parser-parse",
    :source => @source,
  }
  TemporaryFile.create(options) do |image|
    @image = image
    @canvas << ImageTitleSlide.new(@image.path)
  end
end