class Kontena::Plugin::Shell::Context

Attributes

context[R]

Public Class Methods

new(context) click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 7
def initialize(context)
  @context = normalize(context)
end

Public Instance Methods

+(arr) click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 54
def +(arr)
  context + Array(arr)
end
<<(token) click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 24
def <<(token)
  context << token
end
concat(tokens) click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 19
def concat(tokens)
  arg_index = tokens.index { |a| a == '--' || a.start_with?('-') } || tokens.size
  context.concat(tokens[0..arg_index-1])
end
context=(context) click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 36
def context=(context)
  @command = nil
  @context = context
end
empty?() click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 28
def empty?
  context.empty?
end
first() click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 32
def first
  context.first
end
normalize(context) click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 41
def normalize(context)
  return [] if context.nil?
  context.kind_of?(String) ? context.shellsplit : context
end
to_a() click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 50
def to_a
  context
end
to_s() click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 46
def to_s
  context.join(' ')
end
top() click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 15
def top
  context.clear
end
up() click to toggle source
# File lib/kontena/plugin/shell/context.rb, line 11
def up
  context.pop
end