Class: StartupTime::Options
- Inherits:
-
Object
- Object
- StartupTime::Options
- Defined in:
- lib/startup_time/options.rb
Overview
StartupTime::Options - a struct-like interface to the app options set or overridden on the command line
Constant Summary collapse
- BUILD_DIR =
EnvPaths.get('startup-time', suffix: false).cache
- DEFAULT_DURATION =
10
- MINIMUM_DURATION =
2
- Spec =
Value.new(:type, :value)
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#build_dir ⇒ Object
readonly
Returns the value of attribute build_dir.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#rounds ⇒ Object
readonly
Returns the value of attribute rounds.
-
#verbosity ⇒ Object
readonly
Returns the value of attribute verbosity.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #spec ⇒ Object
-
#usage ⇒ Object
the usage message (string) generated by the option parser for this tool.
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/startup_time/options.rb', line 21 def initialize(args) @action = :benchmark @build_dir = BUILD_DIR @duration = DEFAULT_DURATION @format = :default @parser = nil @rounds = nil @spec = nil @verbosity = :default parse! args end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
17 18 19 |
# File 'lib/startup_time/options.rb', line 17 def action @action end |
#build_dir ⇒ Object (readonly)
Returns the value of attribute build_dir.
17 18 19 |
# File 'lib/startup_time/options.rb', line 17 def build_dir @build_dir end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
17 18 19 |
# File 'lib/startup_time/options.rb', line 17 def format @format end |
#rounds ⇒ Object (readonly)
Returns the value of attribute rounds.
17 18 19 |
# File 'lib/startup_time/options.rb', line 17 def rounds @rounds end |
#verbosity ⇒ Object (readonly)
Returns the value of attribute verbosity.
17 18 19 |
# File 'lib/startup_time/options.rb', line 17 def verbosity @verbosity end |
Instance Method Details
#spec ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/startup_time/options.rb', line 34 def spec @spec ||= if @rounds Spec.with(type: :count, value: @rounds) else Spec.with(type: :duration, value: @duration) end end |
#usage ⇒ Object
the usage message (string) generated by the option parser for this tool
43 44 45 |
# File 'lib/startup_time/options.rb', line 43 def usage @parser.to_s end |