Class: DummyImage::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Parser

Returns a new instance of Parser.



3
4
5
6
# File 'lib/parser.rb', line 3

def initialize path, options = {}
    @path, @format = path.split ".", 2
    @options = options
end

Instance Method Details

#bgcolorObject



32
33
34
# File 'lib/parser.rb', line 32

def bgcolor
    @bgcolor ||= valid_color(@options[:bgcolor]) || "000"
end

#fgcolorObject



28
29
30
# File 'lib/parser.rb', line 28

def fgcolor
    @fgcolor ||= valid_color(@options[:fgcolor]) || "fff"
end

#formatObject



8
9
10
11
12
13
14
# File 'lib/parser.rb', line 8

def format
    if %w(png jpg jpeg gif).include? @format
        @format
    else
        "png"
    end
end

#heightObject



20
21
22
# File 'lib/parser.rb', line 20

def height
    @height ||= valid_size(@options[:height]) || "300"
end

#pathObject



16
17
18
# File 'lib/parser.rb', line 16

def path
    @path
end

#widthObject



24
25
26
# File 'lib/parser.rb', line 24

def width
    @width ||= valid_size(@options[:width]) || "300"
end