Class: Skeptick::Convert
- Inherits:
-
Object
- Object
- Skeptick::Convert
- Defined in:
- lib/skeptick/convert.rb,
lib/skeptick/sugar/composition.rb,
lib/skeptick/sugar/composition.rb,
lib/skeptick/convert/dsl_context.rb
Defined Under Namespace
Classes: DslContext
Instance Attribute Summary collapse
-
#appends ⇒ Object
Returns the value of attribute appends.
-
#prepends ⇒ Object
Returns the value of attribute prepends.
Instance Method Summary collapse
- #append(*args) ⇒ Object
- #become_inner ⇒ Object
- #convert(*args, &blk) ⇒ Object
- #destination=(to) ⇒ Object
- #image(obj = nil, &blk) ⇒ Object
-
#initialize(context, *args, &blk) ⇒ Convert
constructor
A new instance of Convert.
- #inspect ⇒ Object
- #parts ⇒ Object
- #piping? ⇒ Boolean
- #prepend(*args) ⇒ Object
- #process_method_missing(*args, &blk) ⇒ Object
- #set(*args) ⇒ Object (also: #apply, #with)
- #to_s ⇒ Object
Methods included from Sugar::Composition::Operators
Methods included from Sugar::Composition::Helper
Methods included from Skeptick::Command::Executable
Constructor Details
#initialize(context, *args, &blk) ⇒ Convert
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/skeptick/convert.rb', line 13 def initialize(context, *args, &blk) @context = context = Helper.(args) @args = args.map {|a| Image.new(@context, a)} @block = blk @to = parse_pipe([:to]) @inner = false @beginning = nil @ending = nil @prepends = [] @appends = [] reset end |
Instance Attribute Details
#appends ⇒ Object
Returns the value of attribute appends.
11 12 13 |
# File 'lib/skeptick/convert.rb', line 11 def appends @appends end |
#prepends ⇒ Object
Returns the value of attribute prepends.
11 12 13 |
# File 'lib/skeptick/convert.rb', line 11 def prepends @prepends end |
Instance Method Details
#append(*args) ⇒ Object
33 34 35 |
# File 'lib/skeptick/convert.rb', line 33 def append(*args) @appends << Helper.process_args(*args) end |
#become_inner ⇒ Object
66 67 68 69 |
# File 'lib/skeptick/convert.rb', line 66 def become_inner @inner = true self end |
#convert(*args, &blk) ⇒ Object
44 45 46 47 48 |
# File 'lib/skeptick/convert.rb', line 44 def convert(*args, &blk) Convert.new(@context, *args, &blk).tap do |c_obj| @objects << Image.new(@context, c_obj) end end |
#destination=(to) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/skeptick/convert.rb', line 54 def destination=(to) if inner? raise 'cannot assign output to parentheses-wrapped image conversion' else @to = to end end |
#image(obj = nil, &blk) ⇒ Object
50 51 52 |
# File 'lib/skeptick/convert.rb', line 50 def image(obj = nil, &blk) @objects << Image.new(@context, obj, &blk) end |
#inspect ⇒ Object
83 84 85 |
# File 'lib/skeptick/convert.rb', line 83 def inspect "Skeptick::Convert(#{to_s})" end |
#parts ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/skeptick/convert.rb', line 71 def parts reset @objects = [] DslContext.new(self).instance_eval(&@block) if @block wrap [@beginning, *@prepends, *@args, *@objects, *@appends, @ending].compact end |
#piping? ⇒ Boolean
62 63 64 |
# File 'lib/skeptick/convert.rb', line 62 def piping? !inner? && parts.last == Chain::PIPE end |
#prepend(*args) ⇒ Object
29 30 31 |
# File 'lib/skeptick/convert.rb', line 29 def prepend(*args) @prepends << Helper.process_args(*args) end |
#process_method_missing(*args, &blk) ⇒ Object
87 88 89 |
# File 'lib/skeptick/convert.rb', line 87 def process_method_missing(*args, &blk) @context.send(*args, &blk) end |
#set(*args) ⇒ Object Also known as: apply, with
37 38 39 |
# File 'lib/skeptick/convert.rb', line 37 def set(*args) @objects << Helper.process_args(*args) end |
#to_s ⇒ Object
79 80 81 |
# File 'lib/skeptick/convert.rb', line 79 def to_s parts.join(' ') end |