Class: Skeptick::Convert
- Inherits:
-
Object
- Object
- Skeptick::Convert
- Defined in:
- lib/skeptick/convert.rb,
lib/skeptick/sugar/compose.rb
Direct Known Subclasses
Constant Summary collapse
- BINARY_PATH =
'convert'.freeze
- DEFAULT_OUTPUT =
'miff:-'.freeze
Instance Attribute Summary collapse
-
#appends ⇒ Object
readonly
Returns the value of attribute appends.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#prepends ⇒ Object
readonly
Returns the value of attribute prepends.
-
#subjects ⇒ Object
readonly
Returns the value of attribute subjects.
Instance Method Summary collapse
- #&(other) ⇒ Object
- #*(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #/(other) ⇒ Object
- #command ⇒ Object
-
#initialize(context, *args, &blk) ⇒ Convert
constructor
A new instance of Convert.
- #inspect ⇒ Object
- #run ⇒ Object
- #shellwords ⇒ Object
- #to_s ⇒ Object
- #|(other) ⇒ Object
Constructor Details
#initialize(context, *args, &blk) ⇒ Convert
Returns a new instance of Convert.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/skeptick/convert.rb', line 11 def initialize(context, *args, &blk) @context = context opts = args.last.is_a?(Hash) ? args.pop : {} @objects = [ @beginning = BINARY_PATH.dup, @prepends = setup_prepends, @subjects = setup_subjects, @appends = setup_appends, @ending = opts.fetch(:to){ DEFAULT_OUTPUT }.dup ] args.each do |arg| subjects << if arg.is_a?(Convert) arg else Convert.new(@context).tap{ |c| c.subjects << arg } end end DslContext.new(self).instance_eval(&blk) if block_given? end |
Instance Attribute Details
#appends ⇒ Object (readonly)
Returns the value of attribute appends.
6 7 8 |
# File 'lib/skeptick/convert.rb', line 6 def appends @appends end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/skeptick/convert.rb', line 6 def context @context end |
#prepends ⇒ Object (readonly)
Returns the value of attribute prepends.
6 7 8 |
# File 'lib/skeptick/convert.rb', line 6 def prepends @prepends end |
#subjects ⇒ Object (readonly)
Returns the value of attribute subjects.
6 7 8 |
# File 'lib/skeptick/convert.rb', line 6 def subjects @subjects end |
Instance Method Details
#&(other) ⇒ Object
30 31 32 33 34 |
# File 'lib/skeptick/sugar/compose.rb', line 30 def &(other) Compose.new(@context, :dstin, self, other).tap do |c| c.subjects << :alpha << 'Set' end end |
#*(other) ⇒ Object
22 23 24 |
# File 'lib/skeptick/sugar/compose.rb', line 22 def *(other) Compose.new(@context, :multiply, self, other) end |
#+(other) ⇒ Object
14 15 16 |
# File 'lib/skeptick/sugar/compose.rb', line 14 def +(other) Compose.new(@context, :over, self, other) end |
#-(other) ⇒ Object
18 19 20 |
# File 'lib/skeptick/sugar/compose.rb', line 18 def -(other) Compose.new(@context, :dstout, self, other) end |
#/(other) ⇒ Object
26 27 28 |
# File 'lib/skeptick/sugar/compose.rb', line 26 def /(other) Compose.new(@context, :divide, self, other) end |
#command ⇒ Object
38 |
# File 'lib/skeptick/convert.rb', line 38 def command; Command.new(shellwords) end |
#inspect ⇒ Object
36 |
# File 'lib/skeptick/convert.rb', line 36 def inspect; "#{self.class}(\"#{to_s}\")" end |
#run ⇒ Object
34 |
# File 'lib/skeptick/convert.rb', line 34 def run; command.run end |
#shellwords ⇒ Object
37 |
# File 'lib/skeptick/convert.rb', line 37 def shellwords; tokens.map { |obj| token_to_str(obj) } end |
#to_s ⇒ Object
35 |
# File 'lib/skeptick/convert.rb', line 35 def to_s; shellwords.join(' ') end |