Class: Princely::Executable
- Inherits:
-
Object
- Object
- Princely::Executable
- Defined in:
- lib/princely/executable.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #check_for_executable ⇒ Object
- #default_executable_path ⇒ Object
-
#initialize(path = nil) ⇒ Executable
constructor
A new instance of Executable.
- #join(options) ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ Executable
Returns a new instance of Executable.
5 6 7 8 9 |
# File 'lib/princely/executable.rb', line 5 def initialize(path=nil) @path = path || default_executable_path check_for_executable end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/princely/executable.rb', line 3 def path @path end |
Instance Method Details
#check_for_executable ⇒ Object
11 12 13 14 |
# File 'lib/princely/executable.rb', line 11 def check_for_executable raise "Cannot find prince command-line app in $PATH" if !@path || @path.length == 0 raise "Cannot find prince command-line app at #{@exe_path}" unless File.executable?(@path) end |
#default_executable_path ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/princely/executable.rb', line 16 def default_executable_path if Princely.ruby_platform =~ /mswin32|minigw32/ "C:/Program Files/Prince/Engine/bin/prince" else `which prince`.chomp end end |
#join(options) ⇒ Object
24 25 26 |
# File 'lib/princely/executable.rb', line 24 def join() ([path] + Array()).join(' ') end |