Class: RubyLiveReload::Options
- Inherits:
-
Object
- Object
- RubyLiveReload::Options
- Defined in:
- lib/ruby_live_reload/options.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
Class Method Summary collapse
Instance Attribute Details
#directory ⇒ Object
Returns the value of attribute directory.
18 19 20 |
# File 'lib/ruby_live_reload/options.rb', line 18 def directory @directory end |
#host ⇒ Object
Returns the value of attribute host.
18 19 20 |
# File 'lib/ruby_live_reload/options.rb', line 18 def host @host end |
#message ⇒ Object
Returns the value of attribute message.
18 19 20 |
# File 'lib/ruby_live_reload/options.rb', line 18 def @message end |
#port ⇒ Object
Returns the value of attribute port.
18 19 20 |
# File 'lib/ruby_live_reload/options.rb', line 18 def port @port end |
#proxy ⇒ Object
Returns the value of attribute proxy.
18 19 20 |
# File 'lib/ruby_live_reload/options.rb', line 18 def proxy @proxy end |
Class Method Details
.parse(args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ruby_live_reload/options.rb', line 20 def self.parse(args) unless [String, Array].include? args.class raise <<~ERROR.strip Provide an array or a space-separated string of arguments: ["-p", 9090, "--host", "198.168.0.42"] or "-p 9090 --host 192.168.0.42" ERROR end args = args.split " " if args.is_a? String instance = Options.new OptionParser.new do || . = "Usage: rlr [instance]" .release = VERSION .on("-b HOST", "--bind HOST", "Hostname") do |host| instance.send :host=, host end .on("-p PORT", "--port PORT", "Port") do |port| instance.send :port=, port end .on("--proxy URL", "Url of the proxied app") do |proxy| instance.send :proxy=, proxy end .on("-d PATH", "--directory PATH", "Path") do |path| directory = if path.start_with?("/") path else File.join(Dir.pwd, path) end # TODO Validate path is a directory instance.send :directory=, directory end .on("-v", "--version", "Version") do instance.send :message=, VERSION end end.parse(args) return instance end |