Class: Pocketbook::CLI::OptionsParser::ParsedOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/pocketbook/cli/options_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParsedOptions

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_msObject

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

#diagnosticsObject (readonly)

Returns the value of attribute diagnostics.



13
14
15
# File 'lib/pocketbook/cli/options_parser.rb', line 13

def diagnostics
  @diagnostics
end

#inputsObject (readonly)

Returns the value of attribute inputs.



13
14
15
# File 'lib/pocketbook/cli/options_parser.rb', line 13

def inputs
  @inputs
end

#metadataObject (readonly)

Returns the value of attribute metadata.



13
14
15
# File 'lib/pocketbook/cli/options_parser.rb', line 13

def 
  @metadata
end

#open_outputObject (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_pathObject

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

#styleObject

Returns the value of attribute style.



13
14
15
# File 'lib/pocketbook/cli/options_parser.rb', line 13

def style
  @style
end

#template_overrideObject

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_pathObject

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_requestObject



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

Raises:

  • (OptionParser::MissingArgument)


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