Class: Pocketbook::CLI::OptionsParser::ParsedOptions
- Inherits:
-
Object
- Object
- Pocketbook::CLI::OptionsParser::ParsedOptions
- Defined in:
- lib/pocketbook/cli/options_parser.rb
Instance Attribute Summary collapse
-
#debounce_ms ⇒ Object
Returns the value of attribute debounce_ms.
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#open_output ⇒ Object
readonly
Returns the value of attribute open_output.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#style ⇒ Object
Returns the value of attribute style.
-
#template_override ⇒ Object
Returns the value of attribute template_override.
-
#theme_path ⇒ Object
Returns the value of attribute theme_path.
Instance Method Summary collapse
- #add_inputs(path_value) ⇒ Object
- #diagnostics! ⇒ Object
-
#initialize ⇒ ParsedOptions
constructor
A new instance of ParsedOptions.
- #metadata_value(key, value) ⇒ Object
- #open_output! ⇒ Object
- #to_request ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ ParsedOptions
Returns a new instance of ParsedOptions.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pocketbook/cli/options_parser.rb', line 15 def initialize @inputs = [] @theme_path = DEFAULT_THEME_PATH @style = nil @template_override = nil @output_path = "output/book.pdf" @metadata = {} @debounce_ms = DEFAULT_DEBOUNCE_MS @diagnostics = false @open_output = false end |
Instance Attribute Details
#debounce_ms ⇒ Object
Returns the value of attribute debounce_ms.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def debounce_ms @debounce_ms end |
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def diagnostics @diagnostics end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def inputs @inputs end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def @metadata end |
#open_output ⇒ Object (readonly)
Returns the value of attribute open_output.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def open_output @open_output end |
#output_path ⇒ Object
Returns the value of attribute output_path.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def output_path @output_path end |
#style ⇒ Object
Returns the value of attribute style.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def style @style end |
#template_override ⇒ Object
Returns the value of attribute template_override.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def template_override @template_override end |
#theme_path ⇒ Object
Returns the value of attribute theme_path.
13 14 15 |
# File 'lib/pocketbook/cli/options_parser.rb', line 13 def theme_path @theme_path end |
Instance Method Details
#add_inputs(path_value) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/pocketbook/cli/options_parser.rb', line 27 def add_inputs(path_value) path_value.to_s.split(",").each do |value| normalized = value.strip next if normalized.empty? @inputs << normalized end end |
#diagnostics! ⇒ Object
62 63 64 |
# File 'lib/pocketbook/cli/options_parser.rb', line 62 def diagnostics! @diagnostics = true end |
#metadata_value(key, value) ⇒ Object
52 53 54 |
# File 'lib/pocketbook/cli/options_parser.rb', line 52 def (key, value) @metadata[key] = value end |
#open_output! ⇒ Object
66 67 68 |
# File 'lib/pocketbook/cli/options_parser.rb', line 66 def open_output! @open_output = true end |
#to_request ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/pocketbook/cli/options_parser.rb', line 74 def to_request Pocketbook::RenderRequest.new( inputs: @inputs, theme_path: @theme_path, style: @style, template_override: @template_override, output_path: @output_path, metadata: @metadata, debounce_ms: @debounce_ms, diagnostics: @diagnostics, open_output: @open_output ) end |
#validate! ⇒ Object
70 71 72 |
# File 'lib/pocketbook/cli/options_parser.rb', line 70 def validate! raise OptionParser::MissingArgument, "at least one markdown input file is required" if @inputs.empty? end |