Class: Rsense::Server::Options
- Inherits:
-
Object
- Object
- Rsense::Server::Options
- Defined in:
- lib/rsense/server/options.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#command ⇒ Object
Returns the value of attribute command.
-
#config ⇒ Object
Returns the value of attribute config.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#file ⇒ Object
Returns the value of attribute file.
-
#location ⇒ Object
Returns the value of attribute location.
-
#log ⇒ Object
Returns the value of attribute log.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#name ⇒ Object
Returns the value of attribute name.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#project_path ⇒ Object
Returns the value of attribute project_path.
-
#rest ⇒ Object
Returns the value of attribute rest.
Instance Method Summary collapse
- #debug? ⇒ Boolean
- #here_doc_reader(reader) ⇒ Object
- #inherit(parent) ⇒ Object
-
#initialize(opts) ⇒ Options
constructor
A new instance of Options.
- #load_config(config) ⇒ Object
- #parse_args(opts) ⇒ Object
- #progress ⇒ Object
- #project ⇒ Object
- #project=(path) ⇒ Object
Constructor Details
#initialize(opts) ⇒ Options
Returns a new instance of Options.
10 11 12 13 14 |
# File 'lib/rsense/server/options.rb', line 10 def initialize(opts) @rest = {} @command = opts["command"] if opts["command"] parse_args(opts) end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def code @code end |
#command ⇒ Object
Returns the value of attribute command.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def command @command end |
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def config @config end |
#debug ⇒ Object
Returns the value of attribute debug.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def debug @debug end |
#file ⇒ Object
Returns the value of attribute file.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def file @file end |
#location ⇒ Object
Returns the value of attribute location.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def location @location end |
#log ⇒ Object
Returns the value of attribute log.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def log @log end |
#log_level ⇒ Object
Returns the value of attribute log_level.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def log_level @log_level end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def name @name end |
#prefix ⇒ Object
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def prefix @prefix end |
#project_path ⇒ Object
Returns the value of attribute project_path.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def project_path @project_path end |
#rest ⇒ Object
Returns the value of attribute rest.
8 9 10 |
# File 'lib/rsense/server/options.rb', line 8 def rest @rest end |
Instance Method Details
#debug? ⇒ Boolean
42 43 44 |
# File 'lib/rsense/server/options.rb', line 42 def debug? @debug end |
#here_doc_reader(reader) ⇒ Object
38 39 40 |
# File 'lib/rsense/server/options.rb', line 38 def here_doc_reader(reader) Rsense::Util::HereDocReader.new(reader, "EOF") end |
#inherit(parent) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/rsense/server/options.rb', line 66 def inherit(parent) if parent.debug? @debug = true end @log = parent.log() @log_level = parent.log_level @load_path = parent.load_path @gem_path = parent.gem_path end |
#load_config(config) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/rsense/server/options.rb', line 76 def load_config(config) path = Pathname.new(config). if path.exist? json = JSON.parse(path.read) parse_args(json) else puts "Config file: #{path} does not exist" end end |
#parse_args(opts) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/rsense/server/options.rb', line 16 def parse_args(opts) opts.each_pair do |k, v| if respond_to?("#{k}=") __send__("#{k}=", v) else @rest[k] = v end end end |
#progress ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/rsense/server/options.rb', line 58 def progress if @progress @progress.to_i else 0 end end |
#project ⇒ Object
26 27 28 |
# File 'lib/rsense/server/options.rb', line 26 def project @project_path end |
#project=(path) ⇒ Object
30 31 32 |
# File 'lib/rsense/server/options.rb', line 30 def project=(path) @project_path = Pathname.new(path). end |