Class: Bwrap::Args::Args
- Inherits:
-
Hash
- Object
- Hash
- Bwrap::Args::Args
- Defined in:
- lib/bwrap/args/args.rb
Overview
Instance Method Summary collapse
-
#add(type, *data) ⇒ Object
Adds given data to array identified by given type.
-
#add_uniq(type, *data) ⇒ Object
Adds ugiven data to array identified by given type if they have not been already added.
-
#initialize(*args) ⇒ Args
constructor
Creates new instance of a hash for storing arguments.
-
#ro_bind(type, path) ⇒ Object
Adds a read-only bind to bind given path from host to same path inside sandbox.
Constructor Details
#initialize(*args) ⇒ Args
Creates new instance of a hash for storing arguments.
Where `Hash` defaults to nil as default argument, Bwrap::Args::Args defaults to `[]`.
22 23 24 25 26 27 28 |
# File 'lib/bwrap/args/args.rb', line 22 def initialize(*args) if args.empty? and !block_given? super(*args) { [] } else super(*args) end end |
Instance Method Details
#add(type, *data) ⇒ Object
Adds given data to array identified by given type.
Following types are meant to be used, though everything is accepted:
-
:mount
-
(and many others, they are not documented here)
38 39 40 41 42 43 44 45 46 |
# File 'lib/bwrap/args/args.rb', line 38 def add(type, *data) if data.respond_to? :each self[type] += data.flatten else self[type] << data end self end |
#add_uniq(type, *data) ⇒ Object
Adds ugiven data to array identified by given type if they have not been already added.
Following types are meant to be used, though everything is accepted:
-
:mount
-
(and many others, they are not documented here)
57 58 59 60 61 62 63 64 65 |
# File 'lib/bwrap/args/args.rb', line 57 def add_uniq(type, *data) if data.respond_to? :each self[type] |= data else self[type] << data unless include? data end self end |
#ro_bind(type, path) ⇒ Object
Adds a read-only bind to bind given path from host to same path inside sandbox.
TODO: doc for params
72 73 74 |
# File 'lib/bwrap/args/args.rb', line 72 def ro_bind(type, path) add(type, %W{ --ro-bind #{path} #{path} }) end |