Class: Vos::Box
- Inherits:
-
Object
- Object
- Vos::Box
- Defined in:
- lib/vos/box.rb,
lib/vos/box/vfs.rb,
lib/vos/box/marks.rb,
lib/vos/box/shell.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
driver.
Attributes included from Shell
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #host ⇒ Object
-
#initialize(*args) ⇒ Box
constructor
A new instance of Box.
-
#inspect ⇒ Object
(also: #to_s)
Miscellaneous.
- #local? ⇒ Boolean
- #open(&block) ⇒ Object
Methods included from Shell
#bash, #bash_without_path, #default_env, #exec, #home, #wrap_cmd
Methods included from Marks
#clear_marks!, #has_mark?, #mark!, #marks_dir
Methods included from Vfs
Constructor Details
#initialize(*args) ⇒ Box
Returns a new instance of Box.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vos/box.rb', line 5 def initialize *args first = args.first if args.empty? @driver = Drivers::Local.new elsif first.is_a?(String) or first.is_a?(Symbol) or first.is_a?(Hash) and (args.size <= 2) if first.is_a? Hash = first [:host] ||= 'localhost' else = args[1] || {} raise 'invalid arguments' unless .is_a?(Hash) [:host] = first.to_s end @driver = [:host] == 'localhost' ? Drivers::Local.new : Drivers::Ssh.new() elsif args.size == 1 @driver = first else raise 'invalid arguments' end @driver.box = self end |
Instance Attribute Details
#driver ⇒ Object (readonly)
driver
32 33 34 |
# File 'lib/vos/box.rb', line 32 def driver @driver end |
Class Method Details
Instance Method Details
#close ⇒ Object
37 38 39 |
# File 'lib/vos/box.rb', line 37 def close driver.close end |
#host ⇒ Object
48 |
# File 'lib/vos/box.rb', line 48 def host; driver.host end |
#inspect ⇒ Object Also known as: to_s
Miscellaneous
45 |
# File 'lib/vos/box.rb', line 45 def inspect; driver.to_s end |
#local? ⇒ Boolean
50 |
# File 'lib/vos/box.rb', line 50 def local?; host == 'localhost' end |
#open(&block) ⇒ Object
34 35 36 |
# File 'lib/vos/box.rb', line 34 def open &block driver.open &block end |