Class: Skeptick::DslContext
- Inherits:
-
Object
- Object
- Skeptick::DslContext
show all
- Includes:
- ResizedImage, RoundedCornersImage, TornPaperImage
- Defined in:
- lib/skeptick/sugar/draw.rb,
lib/skeptick/sugar/font.rb,
lib/skeptick/sugar/swap.rb,
lib/skeptick/sugar/text.rb,
lib/skeptick/dsl_context.rb,
lib/skeptick/sugar/clone.rb,
lib/skeptick/sugar/write.rb,
lib/skeptick/sugar/canvas.rb,
lib/skeptick/sugar/delete.rb,
lib/skeptick/sugar/format.rb,
lib/skeptick/sugar/compose.rb,
lib/skeptick/sugar/resized_image.rb,
lib/skeptick/sugar/torn_paper_image.rb,
lib/skeptick/sugar/rounded_corners_image.rb
Instance Method Summary
collapse
#rounded_corners_image
#torn_paper_image
#resized_image
Constructor Details
#initialize(convert) ⇒ DslContext
Returns a new instance of DslContext.
3
4
5
|
# File 'lib/skeptick/dsl_context.rb', line 3
def initialize(convert)
@convert = convert
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &blk) ⇒ Object
24
25
26
|
# File 'lib/skeptick/dsl_context.rb', line 24
def method_missing(*args, &blk)
@convert.context.send(*args, &blk)
end
|
Instance Method Details
#append(*args) ⇒ Object
15
16
17
|
# File 'lib/skeptick/dsl_context.rb', line 15
def append(*args)
@convert.appends.push(*args)
end
|
#canvas(string, options = {}) ⇒ Object
3
4
5
6
|
# File 'lib/skeptick/sugar/canvas.rb', line 3
def canvas(string, options = {})
set(:size, options[:size]) if options[:size]
set "canvas:#{string}"
end
|
#clone(*args) ⇒ Object
3
4
5
6
7
|
# File 'lib/skeptick/sugar/clone.rb', line 3
def clone(*args)
obj = (args.size < 2 ? args.first : args)
obj = obj.join(',') if obj.is_a?(Array)
obj ? set(:clone, obj) : set('+clone')
end
|
#compose(blending, *args, &blk) ⇒ Object
42
43
44
|
# File 'lib/skeptick/sugar/compose.rb', line 42
def compose(blending, *args, &blk)
@convert.subjects << Compose.new(self, blending, *args, &blk)
end
|
#convert(*args, &blk) ⇒ Object
Also known as:
image
19
20
21
|
# File 'lib/skeptick/dsl_context.rb', line 19
def convert(*args, &blk)
@convert.subjects << Convert.new(self, *args, &blk)
end
|
#delete(*args) ⇒ Object
3
4
5
6
7
|
# File 'lib/skeptick/sugar/delete.rb', line 3
def delete(*args)
obj = (args.size < 2 ? args.first : args)
obj = obj.join(',') if obj.is_a?(Array)
obj ? set(:delete, obj) : set('+delete')
end
|
#draw(*args) ⇒ Object
3
4
5
|
# File 'lib/skeptick/sugar/draw.rb', line 3
def draw(*args)
set :draw, args.join(' ')
end
|
#font(name) ⇒ Object
3
4
5
|
# File 'lib/skeptick/sugar/font.rb', line 3
def font(name)
set '-font', name.split(/\s/).map(&:capitalize).join('-')
end
|
3
4
5
|
# File 'lib/skeptick/sugar/format.rb', line 3
def format(*args)
set '-format', args.join(' ')
end
|
#prepend(*args) ⇒ Object
7
8
9
|
# File 'lib/skeptick/dsl_context.rb', line 7
def prepend(*args)
@convert.prepends.push(*args)
end
|
#respond_to_missing?(meth, include_all) ⇒ Boolean
28
29
30
|
# File 'lib/skeptick/dsl_context.rb', line 28
def respond_to_missing?(meth, include_all)
@convert.context.respond_to?(meth, include_all)
end
|
#set(*args) ⇒ Object
11
12
13
|
# File 'lib/skeptick/dsl_context.rb', line 11
def set(*args)
@convert.subjects.push(*args)
end
|
#swap(*args) ⇒ Object
3
4
5
6
7
8
9
10
|
# File 'lib/skeptick/sugar/swap.rb', line 3
def swap(*args)
if args.size != 0 && args.size != 2
raise ArgumentError,
"wrong number of arguments (#{args.size} for 0, 2)"
end
args.empty? ? set('+swap') : set(:swap, args.join(','))
end
|
#text(string, options = {}) ⇒ Object
3
4
5
6
7
8
9
|
# File 'lib/skeptick/sugar/text.rb', line 3
def text(string, options = {})
if options[:left] && options[:top]
opts = "#{options[:left]},#{options[:top]} "
end
set :draw, "text #{opts}'#{string}'"
end
|
#write(path) ⇒ Object
3
4
5
|
# File 'lib/skeptick/sugar/write.rb', line 3
def write(path)
append(:write, path)
end
|